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: 46.36 ns deviation 1.49 ns (with 50 runs) in [45.21 ns, 47.80 ns]
    {'legend': 'multiplication', 'average': 4.636389203369618e-08, 'deviation': 1.4945549370516326e-09, 'first': 6.419606506824494e-08, 'first3': 5.326544245084127e-08, 'last3': 4.600112636884053e-08, 'repeat': 200, 'min5': 4.5206397771835326e-08, 'max5': 4.779547452926636e-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