See the backing repository for Linear Model here.
Linear / logistic regression, where the relationship between the response and its explanatory variables are modeled with linear predictor functions. This is one of the foundational models in statistical modeling, has quick training time and offers good interpretability, but has varying model performance. The implementation is a light wrapper to the linear / logistic regression exposed in
How it Works¶
The following code will train a logistic regression for the breast cancer dataset. The visualizations provided will be for both global and local explanations.
from interpret import set_visualize_provider from interpret.provider import InlineProvider set_visualize_provider(InlineProvider())
from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from interpret.glassbox import LogisticRegression from interpret import show seed = 1 X, y = load_breast_cancer(return_X_y=True, as_frame=True) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=seed) lr = LogisticRegression(random_state=seed) lr.fit(X_train, y_train) lr_global = lr.explain_global() show(lr_global) lr_local = lr.explain_local(X_test[:5], y_test[:5]) show(lr_local)
/Users/sajenkin/work/interpretml/interpret-venv/lib/python3.9/site-packages/sklearn/linear_model/_logistic.py:763: ConvergenceWarning: lbfgs failed to converge (status=1): STOP: TOTAL NO. of ITERATIONS REACHED LIMIT. Increase the number of iterations (max_iter) or scale the data as shown in: https://scikit-learn.org/stable/modules/preprocessing.html Please also refer to the documentation for alternative solver options: https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression n_iter_i = _check_optimize_result(