GLM Linear Regression (Bike Sharing)

Experiment initialization and data preparation

from piml import Experiment
from piml.models import GLMRegressor

exp = Experiment()
exp.data_loader(data="BikeSharing", silent=True)
exp.data_summary(feature_exclude=["yr", "mnth", "temp"], silent=True)
exp.data_prepare(target="cnt", task_type="regression", silent=True)

Train Model

exp.model_train(model=GLMRegressor(), name="GLM")

Evaluate predictive performance

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

Train   0.0225   0.1105  0.3467
Test    0.0225   0.1090  0.3593
Gap    -0.0000  -0.0015  0.0127

Regression coefficient plot for numerical features

exp.model_interpret(model="GLM", show="glm_coef_plot", figsize=(5, 4))
Model Coefficients

Regression coefficient plot for categorical features

exp.model_interpret(model="GLM", show="glm_coef_plot", uni_feature="season", figsize=(5, 4))
Model Coefficients

Regression coefficient table for all features

exp.model_interpret(model="GLM", show="glm_coef_table")

Feature importance plot

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

Local interpretation without centering

exp.model_interpret(model="GLM", show="local_fi", sample_id=0, centered=False, original_scale=False, figsize=(5, 4))
Predicted: 0.1058 | Actual: 0.1600

Local interpretation with original scale of x

exp.model_interpret(model="GLM", show='local_fi', sample_id=0, centered=False, original_scale=True, figsize=(5, 4))
Predicted: 0.1058 | Actual: 0.1600

Local interpretation with centering and original scale of x

exp.model_interpret(model="GLM", show='local_fi', sample_id=0, centered=True, original_scale=True, figsize=(5, 4))
Predicted: 0.1058 | Actual: 0.1600

Global feature importance based on test data.

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

Local interpretation for test set data with index 0.

exp.model_interpret(model="GLM", show="local_fi", sample_id=0, use_test=True,
                    original_scale=True, figsize=(5, 4))
Predicted: 0.1163 | Actual: 0.0062

Total running time of the script: ( 1 minutes 43.829 seconds)

Estimated memory usage: 31 MB

Gallery generated by Sphinx-Gallery