Note
Go to the end to download the full example code or to run this example in your browser via Binder
Tree Regression (California Housing)¶
Experiment initialization and data preparation
from piml import Experiment
from piml.models import TreeRegressor
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=TreeRegressor(max_depth=6), name="Tree")
Evaluate predictive performance
exp.model_diagnose(model="Tree", show="accuracy_table")
MSE MAE R2
Train 0.0184 0.0979 0.6762
Test 0.0212 0.1059 0.6178
Gap 0.0028 0.0080 -0.0584
Global interpretation starting from the root node
exp.model_interpret(model="Tree", show="tree_global", root=0, depth=3,
original_scale=True, figsize=(16, 10))

Global interpretation starting from the second node
exp.model_interpret(model="Tree", show="tree_global", root=2, depth=3,
original_scale=True, figsize=(16, 10))

Local interpretation
exp.model_interpret(model="Tree", show="tree_local", sample_id=0,
original_scale=True, figsize=(16, 10))

Total running time of the script: ( 0 minutes 41.834 seconds)
Estimated memory usage: 27 MB