.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\3_models\plot_4_xgb1_cls.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_4_xgb1_cls.py: XGB-1 Classification (CoCircles) ===================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Experiment initialization and data preparation .. GENERATED FROM PYTHON SOURCE LINES 9-16 .. code-block:: default from piml import Experiment from piml.models import XGB1Classifier exp = Experiment() exp.data_loader(data="CoCircles", silent=True) exp.data_prepare(target="target", task_type="classification", silent=True) .. GENERATED FROM PYTHON SOURCE LINES 17-18 Train Model .. GENERATED FROM PYTHON SOURCE LINES 18-20 .. code-block:: default exp.model_train(model=XGB1Classifier(n_estimators=100, max_bin=20, min_bin_size=0.01), name="XGB1") .. GENERATED FROM PYTHON SOURCE LINES 21-22 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: default exp.model_diagnose(model="XGB1", show='accuracy_table') .. rst-class:: sphx-glr-script-out .. code-block:: none ACC AUC F1 LogLoss Brier Train 0.8512 0.9311 0.8499 0.3327 0.1052 Test 0.8450 0.9028 0.8368 0.4084 0.1214 Gap -0.0062 -0.0283 -0.0131 0.0758 0.0162 .. GENERATED FROM PYTHON SOURCE LINES 25-26 Global effect plot for X0 .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: default exp.model_interpret(model="XGB1", show="global_effect_plot", uni_feature="X0", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_001.png :alt: X0 (48.9%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 29-30 Global effect plot for X1 .. GENERATED FROM PYTHON SOURCE LINES 30-32 .. code-block:: default exp.model_interpret(model="XGB1", show="global_effect_plot", uni_feature="X1", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_002.png :alt: X1 (51.1%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-34 Weight of evidence plot for X0 .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: default exp.model_interpret(model="XGB1", show="xgb1_woe", uni_feature="X0", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_003.png :alt: WoE of X0 (IV: 0.8005) :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 Weight of evidence plot for X1 .. GENERATED FROM PYTHON SOURCE LINES 38-40 .. code-block:: default exp.model_interpret(model="XGB1", show="xgb1_woe", uni_feature="X1", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_004.png :alt: WoE of X1 (IV: 0.8858) :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-42 Feature importance .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: default exp.model_interpret(model="XGB1", show="global_fi", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_005.png :alt: Feature Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 45-46 Information value plot .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: default exp.model_interpret(model="XGB1", show="xgb1_iv", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_006.png :alt: Information Value :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 49-50 Local interpretation .. GENERATED FROM PYTHON SOURCE LINES 50-51 .. code-block:: default exp.model_interpret(model="XGB1", show="local_fi", sample_id=0, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_007.png :alt: Predicted: 0.1712 | Actual: 1.0000 :srcset: /auto_examples/3_models/images/sphx_glr_plot_4_xgb1_cls_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 26.187 seconds) **Estimated memory usage:** 17 MB .. _sphx_glr_download_auto_examples_3_models_plot_4_xgb1_cls.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_4_xgb1_cls.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_4_xgb1_cls.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_4_xgb1_cls.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_