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)[source]

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)[source]

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.66 ns deviation 1.62 ns (with 50 runs) in [45.40 ns, 48.00 ns]
    {'legend': 'multiplication', 'average': 4.666234599426389e-08, 'deviation': 1.6238881016631836e-09, 'first': 6.620073691010475e-08, 'first3': 5.3800176829099654e-08, 'last3': 4.6667022009690604e-08, 'repeat': 200, 'min5': 4.540197551250458e-08, 'max5': 4.800036549568176e-08, 'code': '3 * 45535266234653452', 'run': 50}

source on GitHub

jupytalk.benchmark.mlprediction.unit(x)[source]

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