Interpretable Regression#

In this notebook we will fit regression explainable boosting machine (EBM), LinearRegression, and RegressionTree models. After fitting them, we will use their glassbox nature to understand their global and local explanations.

This notebook can be found in our examples folder on GitHub.

# install interpret if not already installed
try:
    import interpret
except ModuleNotFoundError:
    !pip install --quiet interpret scikit-learn
import numpy as np
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from interpret import show
from interpret.perf import RegressionPerf

from interpret import set_visualize_provider
from interpret.provider import InlineProvider
set_visualize_provider(InlineProvider())

dataset = fetch_california_housing()
X = dataset.data
y = dataset.target
names = dataset.feature_names

seed = 42
np.random.seed(seed)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=seed)

Explore the dataset

from interpret import show
from interpret.data import Marginal

marginal = Marginal(names).explain_data(X_train, y_train, name='Train Data')
show(marginal)