module benchmark.mlprediction

Short summary

module jupytalk.benchmark.mlprediction

source on GitHub

Functions

function

truncated documentation

make_dataframe

Builds a dataframe from multiple arrays.

timeexec

Measures the time for a given expression.

unit

Optimizes the rendering of time.

Documentation

source on GitHub

jupytalk.benchmark.mlprediction.make_dataframe(labels, arrays)

Builds a dataframe from multiple arrays.

Parameters
  • labels – list of labels

  • arrays – list of arrays (or one array)

Returns

dataframes

source on GitHub

jupytalk.benchmark.mlprediction.timeexec(legend, code, number=50, repeat=200, verbose=True, context=None)

Measures the time for a given expression.

Parameters
  • legend – name of the experiment

  • code – code to measure (as a string)

  • number – number of time to run the expression (and then divide by this number to get an average)

  • repeat – number of times to repeat the computation of the above average

  • verbose – print the time

  • globals – context (usuable equal to globals())

Returns

dictionary

<<<

from jupytalk.benchmark.mlprediction import timeexec

code = "3 * 45535266234653452"
print(timeexec("multiplication", code))

>>>

    Average: 41.75 ns deviation 2.11 ns (with 50 runs) in [40.61 ns, 43.03 ns]
    {'legend': 'multiplication', 'average': 4.174597561359405e-08, 'deviation': 2.1054607494149415e-09, 'first': 6.940215826034546e-08, 'first3': 5.206714073816935e-08, 'last3': 4.10651167233785e-08, 'repeat': 200, 'min5': 4.0605664253234865e-08, 'max5': 4.302710294723511e-08, 'code': '3 * 45535266234653452', 'run': 50}

source on GitHub

jupytalk.benchmark.mlprediction.unit(x)

Optimizes the rendering of time.

<<<

from jupytalk.benchmark.mlprediction import unit

print(unit(34))
print(unit(3.4))
print(unit(0.34))
print(unit(0.034))
print(unit(0.0034))
print(unit(0.00034))
print(unit(0.000034))
print(unit(0.0000034))
print(unit(0.00000034))

>>>

    34.00 s
    3.40 s
    340.00 ms
    34.00 ms
    3.40 ms
    340.00 µs
    34.00 µs
    3.40 µs
    340.00 ns

source on GitHub