Calmcode - matplot gif: hyper


1 2 3 4 5

The final example demonstrates how you can use a gif to explain what a hyperparameter does in a machine learning model.

import gif
import numpy as np
import matplotlib.pylab as plt
from IPython.display import Image
from sklearn.ensemble import RandomForestRegressor

def frame(i):
    mod = RandomForestRegressor(n_estimators=1, max_depth=i), 1), y)
    plt.plot(x, y)
    plt.plot(x, mod.predict(x.reshape(-1, 1)))

frames = [frame(i) for i in range(100)], "rf.gif", duration=300)

A thing to remember: gifs can help explain something but it should never replace a simple line chart. Don't over-use them.