.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\3_models\plot_5_xgb2_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_5_xgb2_reg.py: XGB-2 Regression (Bike Sharing) ===================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Experiment initialization and data preparation .. GENERATED FROM PYTHON SOURCE LINES 9-17 .. code-block:: default from piml import Experiment from piml.models import XGB2Regressor 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) .. GENERATED FROM PYTHON SOURCE LINES 18-19 Train Model .. GENERATED FROM PYTHON SOURCE LINES 19-21 .. code-block:: default exp.model_train(model=XGB2Regressor(), name="XGB2") .. GENERATED FROM PYTHON SOURCE LINES 22-23 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 23-25 .. code-block:: default exp.model_diagnose(model="XGB2", show="accuracy_table") .. rst-class:: sphx-glr-script-out .. code-block:: none MSE MAE R2 Train 0.0090 0.0669 0.7382 Test 0.0095 0.0688 0.7287 Gap 0.0005 0.0019 -0.0095 .. GENERATED FROM PYTHON SOURCE LINES 26-27 Global effect plot for season .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: default exp.model_interpret(model="XGB2", show="global_effect_plot", uni_feature="season", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_001.png :alt: season (1.3%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 30-31 Global effect plot for hr .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: default exp.model_interpret(model="XGB2", show="global_effect_plot", uni_feature="atemp", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_002.png :alt: atemp (18.4%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 34-35 Global effect plot for hr and season .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: default exp.model_interpret(model="XGB2", show="global_effect_plot", bi_features=["hr", "season"], sliced_line=False, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_003.png :alt: season x hr (0.3%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 Effect importance .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: default exp.model_interpret(model="XGB2", show="global_ei", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_004.png :alt: Effect Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-44 Feature importance .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: default exp.model_interpret(model="XGB2", show="global_fi", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_005.png :alt: Feature Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-48 Local interpretation by effect .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: default exp.model_interpret(model="XGB2", show="local_ei", sample_id=0, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_006.png :alt: Predicted: 0.0782 | Actual: 0.1600 :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-52 Local interpretation by feature .. GENERATED FROM PYTHON SOURCE LINES 52-53 .. code-block:: default exp.model_interpret(model="XGB2", show="local_fi", sample_id=0, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_007.png :alt: Predicted: 0.0782 | Actual: 0.1600 :srcset: /auto_examples/3_models/images/sphx_glr_plot_5_xgb2_reg_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 31.947 seconds) **Estimated memory usage:** 31 MB .. _sphx_glr_download_auto_examples_3_models_plot_5_xgb2_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_5_xgb2_reg.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_5_xgb2_reg.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_5_xgb2_reg.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_