diff --git a/formula.py b/formula.py new file mode 100644 index 0000000..2909f62 --- /dev/null +++ b/formula.py @@ -0,0 +1,21 @@ +# %% +%pip install formulae -U +%pip install formulaic -U + +# %% +import seaborn as sns +from formulae import design_matrices +from formulaic import Formula, model_matrix +import numpy as np + +DATA = sns.load_dataset('iris') + +design_matrix = design_matrices('sepal_length ~ C(species)*petal_width + 1', DATA) + +design_matrix.data + +y, X = model_matrix('sepal_length ~ species*{np.mean(petal_width)} + 1', DATA) + +X.info() + +sns.catplot(data=X.melt(), x='variable', y='value', hue='variable')