... patsy.

There are many ways to get data from pandas to scikit-learn but when you're hacking in a notebook you may prefer to have something that is expressive. Like a domain specific grammar. The tool patsy offers exactly this by mocking features from the R language.


To run the scikit-learn model, you need to run;

from sklearn.linear_model import LinearRegression
import matplotlib.pylab as plt

df_ml = df_clean.head(100)
y, X = ps.dmatrices("n_born ~ wday + yday", df_ml)
mod = LinearRegression().fit(X, y)

plt.figure(figsize=(12, 3))
plt.scatter(df_ml['date'], y)
plt.plot(df_ml['date'], mod.predict(X), color='orange');

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.