.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\3_models\plot_8_reludnn_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_8_reludnn_cls.py: ReLU DNN Classification (Taiwan Credit) ========================================= .. 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 ReluDNNClassifier 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 18-19 Train Model .. GENERATED FROM PYTHON SOURCE LINES 19-21 .. code-block:: default exp.model_train(model=ReluDNNClassifier(hidden_layer_sizes=(40, 40), l1_reg=0.0002, learning_rate=0.001), name="ReLUDNN") .. GENERATED FROM PYTHON SOURCE LINES 22-23 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 23-25 .. code-block:: default exp.model_diagnose(model='ReLUDNN', show="accuracy_table") .. rst-class:: sphx-glr-script-out .. code-block:: none ACC AUC F1 LogLoss Brier Train 0.8200 0.7723 0.4722 0.4334 0.1357 Test 0.8300 0.7708 0.4817 0.4250 0.1317 Gap 0.0100 -0.0015 0.0095 -0.0083 -0.0039 .. GENERATED FROM PYTHON SOURCE LINES 26-27 Local Linear Model (LLM) summary plot .. GENERATED FROM PYTHON SOURCE LINES 27-28 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="llm_summary", figsize=(5, 4)) .. rst-class:: sphx-glr-script-out .. code-block:: none Count Response Mean Response Std Local AUC Global AUC 0 6535.0 0.1053 0.3069 0.6037 0.7349 1 4166.0 0.1066 0.3086 0.6477 0.6261 2 1307.0 0.2295 0.4207 0.5999 0.5003 3 1158.0 0.3100 0.4627 0.7819 0.7348 4 903.0 0.1595 0.3663 0.6118 0.5528 .. ... ... ... ... ... 300 1.0 1.0000 0.0000 NaN 0.7334 301 1.0 0.0000 0.0000 NaN 0.4979 302 1.0 1.0000 0.0000 NaN 0.7322 303 1.0 1.0000 0.0000 NaN 0.7364 304 1.0 0.0000 0.0000 NaN 0.6900 [305 rows x 5 columns] .. GENERATED FROM PYTHON SOURCE LINES 29-30 Local Linear Model (LLM) parallel coordinate plot .. GENERATED FROM PYTHON SOURCE LINES 30-31 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="llm_pc", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_001.png :alt: Parallel Coordinate Plot of LLM Coefficients :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 32-33 Local Linear Model (LLM) violin plot .. GENERATED FROM PYTHON SOURCE LINES 33-34 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="llm_violin", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_002.png :alt: Violin Plot of LLM Coefficients :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-36 Global feature importance .. GENERATED FROM PYTHON SOURCE LINES 36-37 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="global_fi", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_003.png :alt: Feature Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 38-39 Global effect plot: with one feature .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="global_effect_plot", uni_feature="PAY_1", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_004.png :alt: LLM Feature Importance of PAY_1: 62.54% :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 42-43 Global effect plot: with two features .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="global_effect_plot", bi_features=["PAY_1", "PAY_3"], original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_005.png :alt: PAY_1, PAY_3 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-48 Local feature importance without centering .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="local_fi", sample_id=0, centered=False, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_006.png :alt: Predicted: 0.3117 | Actual: 0.0000 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-52 Local feature importance with centering .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: default exp.model_interpret(model="ReLUDNN", show="local_fi", sample_id=0, centered=True, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_007.png :alt: Predicted: 0.3117 | Actual: 0.0000 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_cls_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 50.871 seconds) **Estimated memory usage:** 120 MB .. _sphx_glr_download_auto_examples_3_models_plot_8_reludnn_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_8_reludnn_cls.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_8_reludnn_cls.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_8_reludnn_cls.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_