Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

modelmatrix

modelmatrix builds model matrices from tabular data. Its ModelSpec is a scikit-learn transformer: a list of terms (columns, categorical encodings, polynomials, splines, principal components and their interactions) is fit to a pd.DataFrame, a polars or pyarrow frame or an np.ndarray, and transforms new data the same way. It goes in a Pipeline, and the parameters of its terms are tuned with GridSearchCV.

pip install modelmatrix

ModelSpec was written for the labs of An Introduction to Statistical Learning with Python, whose ISLP package provides the data used on these pages. For more information, visit the GitHub repository.