.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\3_models\plot_2_tree_reg.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_3_models_plot_2_tree_reg.py: Tree Regression (California Housing) ========================================= .. GENERATED FROM PYTHON SOURCE LINES 7-8 Experiment initialization and data preparation .. GENERATED FROM PYTHON SOURCE LINES 8-15 .. code-block:: default 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) .. GENERATED FROM PYTHON SOURCE LINES 16-17 Train Model .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: default exp.model_train(model=TreeRegressor(max_depth=6), name="Tree") .. GENERATED FROM PYTHON SOURCE LINES 20-21 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: default exp.model_diagnose(model="Tree", show="accuracy_table") .. rst-class:: sphx-glr-script-out .. code-block:: none MSE MAE R2 Train 0.0184 0.0979 0.6762 Test 0.0212 0.1059 0.6178 Gap 0.0028 0.0080 -0.0584 .. GENERATED FROM PYTHON SOURCE LINES 24-25 Global interpretation starting from the root node .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: default exp.model_interpret(model="Tree", show="tree_global", root=0, depth=3, original_scale=True, figsize=(16, 10)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_001.png :alt: plot 2 tree reg :srcset: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 29-30 Global interpretation starting from the second node .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: default exp.model_interpret(model="Tree", show="tree_global", root=2, depth=3, original_scale=True, figsize=(16, 10)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_002.png :alt: plot 2 tree reg :srcset: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 34-35 Local interpretation .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: default exp.model_interpret(model="Tree", show="tree_local", sample_id=0, original_scale=True, figsize=(16, 10)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_003.png :alt: plot 2 tree reg :srcset: /auto_examples/3_models/images/sphx_glr_plot_2_tree_reg_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 41.834 seconds) **Estimated memory usage:** 27 MB .. _sphx_glr_download_auto_examples_3_models_plot_2_tree_reg.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/selfexplainml/piml-toolbox/main?urlpath=lab/tree/./docs/_build/html/notebooks/auto_examples/3_models/plot_2_tree_reg.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_2_tree_reg.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_2_tree_reg.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_