vincentarelbundock / pymarginaleffects

GNU General Public License v3.0
47 stars 8 forks source link

Support: `formulaic` and `scikit-learn` #35

Open vincentarelbundock opened 9 months ago

vincentarelbundock commented 9 months ago

https://github.com/matthewwardrop/formulaic

Probably need another argument for the formula used to create y and X in scikit-learn

vincentarelbundock commented 9 months ago
import pandas
import polars as pl
from formulaic import model_matrix
from sklearn.linear_model import LinearRegression

df = pl.read_csv("https://vincentarelbundock.github.io/Rdatasets/csv/causaldata/thornton_hiv.csv")

y, X = model_matrix("got ~ distvct + tinc * age", df.to_pandas())

lr = LinearRegression()
lr.fit(X, y)

X.model_spec.variables

X.model_spec.formula
vincentarelbundock commented 9 months ago

Do we care about this since there are no standard errors in scikit?