Creëren van boxplots:

 

def predict_egg_weight(chicken):
    y = eieren_tijd[chicken].dropna()
    x = (y.index - y.index[0]).days.values.reshape(-1, 1)
    y = y.values
    
    linear_regressor = LinearRegression()
    linear_regressor.fit(x, y)
    y_pred = linear_regressor.predict(x)
    
    return (x, y, y_pred)

fig, axs = plt.subplots(2, 4, sharey=True)

chickens = np.delete(eieren_tijd.columns.values, np.where(eieren_tijd.columns.values == 'Vera')).reshape(2, 4)

for iy, ix in np.ndindex(chickens.shape):
    chicken = chickens[iy, ix]
    axs[iy, ix].set_title(chicken)
    x, y, y_pred = predict_egg_weight(chicken)
    axs[iy, ix].scatter(x, y)
    axs[iy, ix].plot(x, y_pred, color='red')