memo:
conclusion
Sometimes you're experimenting away in a notebook but you want to have a stable method of collecting metrics for your experiments. Memo is a lightweight tool that might help out in these situations.
Notes
We're using the same data collecting code.
import numpy as np
from memo import memlist, memfile, memfunc, memweb
data = []
@memlist(data=data)
def birthday_experiment(class_size, n_sim=1000):
"""Simulates the birthday paradox. Vectorized = Fast!"""
sims = np.random.randint(1, 365 + 1, (n_sim, class_size))
sort_sims = np.sort(sims, axis=1)
n_uniq = (sort_sims[:, 1:] != sort_sims[:, :-1]).sum(axis = 1) + 1
return {"est_prob": np.mean(n_uniq != class_size), "number": 42}
settings = grid(
class_size=range(2, 100),
n_sim=[1_000, 10_000, 100_000]
)
for setting in settings:
birthday_experiment(**setting)
But now we're visualising it with hiplot.
import hiplot as hip
hip.Experiment.from_iterable(data).display()
For more information on hiplot
you might enjoy our tutorial here.
Feedback? See an issue? Something unclear? Feel free to mention it here.
If you want to be kept up to date, consider signing up for the newsletter.