GAM Regression (California Housing)

Experiment initialization and data preparation

from piml import Experiment
from piml.models import GAMRegressor

exp = Experiment()
exp.data_loader(data="CaliforniaHousing_trim2", silent=True)
exp.data_prepare(target="MedHouseVal", task_type="regression", silent=True)

Train Model

exp.model_train(model=GAMRegressor(spline_order=1, n_splines=20, lam=0.6), name="GAM")

Evaluate predictive performance

exp.model_diagnose(model="GAM", show="accuracy_table")
          MSE     MAE       R2

Train  0.0145  0.0867   0.7453
Test   0.0152  0.0883   0.7257
Gap    0.0007  0.0017  -0.0196

Global interpretation: effect plot

exp.model_interpret(model="GAM", show="global_effect_plot", uni_feature="MedInc",
                    original_scale=True, figsize=(5, 4))
MedInc (19.7%)

Global interpretation: feature importance

exp.model_interpret(model="GAM", show="global_fi", figsize=(5, 4))
Feature Importance

Local interpretation

exp.model_interpret(model="GAM", show="local_fi", sample_id=0,
                    original_scale=True, figsize=(5, 4))
Predicted: 0.3804 | Actual: 1.0000

Local interpretation

exp.model_interpret(model="GAM", show="local_fi", sample_id=10,
                    original_scale=True, figsize=(5, 4))
Predicted: 0.3839 | Actual: 0.3885

Total running time of the script: ( 0 minutes 59.951 seconds)

Estimated memory usage: 150 MB

Gallery generated by Sphinx-Gallery