.. 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_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_8_reludnn_reg.py: ReLU DNN Regression (Friedman) ===================================== .. 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 ReluDNNRegressor exp = Experiment() exp.data_loader(data="Friedman", silent=True) exp.data_summary(silent=True) exp.data_prepare(target="target", task_type="regression", silent=True) .. GENERATED FROM PYTHON SOURCE LINES 18-19 Train Model .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: default exp.model_train(model=ReluDNNRegressor(hidden_layer_sizes=(40, 40), l1_reg=0.0002, learning_rate=0.001), name="ReLU-DNN") .. GENERATED FROM PYTHON SOURCE LINES 23-24 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: default exp.model_diagnose(model='ReLU-DNN', show="accuracy_table") .. rst-class:: sphx-glr-script-out .. code-block:: none MSE MAE R2 Train 0.0007 0.0192 0.9784 Test 0.0009 0.0199 0.9709 Gap 0.0002 0.0007 -0.0075 .. GENERATED FROM PYTHON SOURCE LINES 27-28 Local Linear Model (LLM) summary plot .. GENERATED FROM PYTHON SOURCE LINES 28-29 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="llm_summary", figsize=(5, 4)) .. rst-class:: sphx-glr-script-out .. code-block:: none Count Response Mean Response Std Local MSE Global MSE 0 215.0 0.4711 0.1584 0.0005 0.0309 1 207.0 0.4700 0.1648 0.0005 0.0327 2 185.0 0.4592 0.1754 0.0004 0.0324 3 148.0 0.4698 0.1601 0.0003 0.0340 4 126.0 0.3969 0.1574 0.0005 0.0186 5 106.0 0.3815 0.1582 0.0003 0.0218 6 65.0 0.6136 0.1315 0.0013 0.0783 7 62.0 0.6301 0.1698 0.0008 0.0750 8 48.0 0.3266 0.1242 0.0003 0.0542 9 45.0 0.2920 0.1354 0.0002 0.0551 10 43.0 0.6213 0.1345 0.0009 0.0783 11 40.0 0.6046 0.1563 0.0008 0.0750 12 37.0 0.2811 0.1128 0.0003 0.0560 13 36.0 0.5604 0.1171 0.0014 0.0784 14 35.0 0.2250 0.1211 0.0002 0.0288 15 26.0 0.2636 0.1341 0.0002 0.0604 16 24.0 0.5663 0.1579 0.0037 0.0783 17 23.0 0.5213 0.1795 0.0010 0.0441 18 22.0 0.5491 0.1967 0.0010 0.0451 19 20.0 0.6115 0.1256 0.0023 0.0750 20 18.0 0.5365 0.1195 0.0008 0.0784 21 16.0 0.4459 0.1685 0.0024 0.0784 22 13.0 0.2393 0.1061 0.0003 0.0342 23 12.0 0.3573 0.1770 0.0010 0.0404 24 8.0 0.4821 0.1186 0.0007 0.0135 25 3.0 0.4592 0.0625 0.0014 0.0238 26 3.0 0.5134 0.0839 0.0016 0.0138 27 3.0 0.4321 0.1450 0.0164 0.0783 28 2.0 0.1801 0.0305 0.0385 0.0784 29 2.0 0.4558 0.0107 0.0010 0.0240 30 2.0 0.1400 0.0890 0.0040 0.0302 31 2.0 0.2187 0.1037 0.0203 0.0751 32 1.0 0.6258 0.0000 0.0010 0.0943 33 1.0 0.5209 0.0000 0.0035 0.0884 34 1.0 0.4773 0.0000 0.0016 0.0875 .. GENERATED FROM PYTHON SOURCE LINES 30-31 Local Linear Model (LLM) parallel coordinate plot .. GENERATED FROM PYTHON SOURCE LINES 31-32 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="llm_pc", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_001.png :alt: Parallel Coordinate Plot of LLM Coefficients :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-34 Local Linear Model (LLM) violin plot .. GENERATED FROM PYTHON SOURCE LINES 34-35 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="llm_violin", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_002.png :alt: Violin Plot of LLM Coefficients :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 36-37 Global feature importance .. GENERATED FROM PYTHON SOURCE LINES 37-38 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="global_fi", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_003.png :alt: Feature Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 Global effect plot with one feature .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="global_effect_plot", uni_feature="X0", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_004.png :alt: LLM Feature Importance of X0: 25.72% :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 44-45 Global effect plot with two features .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: default exp.model_interpret(model="ReLU-DNN", show="global_effect_plot", bi_features=["X0", "X2"], original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_005.png :alt: X0, X2 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 49-50 Local feature importance without centering .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: default exp.model_interpret(model="ReLU-DNN", 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_reg_006.png :alt: Predicted: 0.3369 | Actual: 0.3549 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 53-54 Local feature importance with centering .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: default exp.model_interpret(model="ReLU-DNN", 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_reg_007.png :alt: Predicted: 0.3369 | Actual: 0.3549 :srcset: /auto_examples/3_models/images/sphx_glr_plot_8_reludnn_reg_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 2 minutes 0.526 seconds) **Estimated memory usage:** 25 MB .. _sphx_glr_download_auto_examples_3_models_plot_8_reludnn_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_8_reludnn_reg.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_8_reludnn_reg.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_8_reludnn_reg.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_