.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\4_testing\plot_2_overfit_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_4_testing_plot_2_overfit_cls.py: Overfit: Classification ===================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Experiment initialization and data preparation .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: default from piml import Experiment from piml.models import XGB2Classifier .. GENERATED FROM PYTHON SOURCE LINES 13-14 Load data and train models. .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: default exp = Experiment() exp.data_loader(data="TaiwanCredit", silent=True) exp.data_summary(feature_exclude=["LIMIT_BAL", "SEX", "EDUCATION", "MARRIAGE", "AGE"], silent=True) exp.data_prepare(target="FlagDefault", task_type="classification", silent=True) .. GENERATED FROM PYTHON SOURCE LINES 20-21 Train Model .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: default exp.model_train(XGB2Classifier(), name="XGB2") .. GENERATED FROM PYTHON SOURCE LINES 24-25 Histogram-based overfit test for a single feature .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: default results = exp.model_diagnose(model="XGB2", show="overfit", slice_method="histogram", slice_features=["BILL_AMT1"], threshold=1.05, min_samples=20, original_scale=True, return_data=True, figsize=(5, 4)) results.data .. image-sg:: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_001.png :alt: Overfit Regions :srcset: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_001.png :class: sphx-glr-single-img .. raw:: html
[BILL_AMT1 BILL_AMT1) #Test #Train test_ACC train_ACC Gap
0 0.2879 0.3781 41 131 0.7561 0.8473 -0.0912


.. GENERATED FROM PYTHON SOURCE LINES 30-31 Histogram-based overfit test for two features .. GENERATED FROM PYTHON SOURCE LINES 31-36 .. code-block:: default results = exp.model_diagnose(model="XGB2", show="overfit", slice_method="histogram", slice_features=["PAY_1", "BILL_AMT1"], threshold=1.05, min_samples=20, original_scale=True, return_data=True, figsize=(5, 4)) results.data .. image-sg:: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_002.png :alt: Overfit Regions :srcset: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_002.png :class: sphx-glr-single-img .. raw:: html
[PAY_1 PAY_1) [BILL_AMT1 BILL_AMT1) #Test #Train test_ACC train_ACC Gap
0 0.2222 0.3333 0.7167 0.8037 30 117 0.6333 0.7094 -0.0761
1 0.3333 0.4444 0.7311 0.7953 40 160 0.6000 0.7000 -0.1000
2 0.3333 0.4444 0.9237 0.9558 69 338 0.5797 0.6834 -0.1037
3 0.2222 0.3333 0.2814 0.3685 24 75 0.7083 0.8133 -0.1050
4 0.0000 0.1111 0.6213 0.6715 20 73 0.6500 0.7808 -0.1308


.. GENERATED FROM PYTHON SOURCE LINES 37-38 Histogram-based overfit test for a single feature on test set .. GENERATED FROM PYTHON SOURCE LINES 38-42 .. code-block:: default results = exp.model_diagnose(model="XGB2", show="overfit", slice_method="histogram", slice_features=["BILL_AMT1"], threshold=1.05, min_samples=20, use_test=True, original_scale=True, return_data=True, figsize=(5, 4)) results.data .. image-sg:: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_003.png :alt: Overfit Regions :srcset: /auto_examples/4_testing/images/sphx_glr_plot_2_overfit_cls_003.png :class: sphx-glr-single-img .. raw:: html
[BILL_AMT1 BILL_AMT1) #Test #Train test_ACC train_ACC Gap
0 0.2879 0.3781 41 131 0.7561 0.8473 -0.0912


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 35.038 seconds) **Estimated memory usage:** 40 MB .. _sphx_glr_download_auto_examples_4_testing_plot_2_overfit_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/4_testing/plot_2_overfit_cls.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_2_overfit_cls.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_2_overfit_cls.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_