.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\3_models\plot_1_gam_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_1_gam_cls.py: GAM 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 GAMClassifier 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=GAMClassifier(spline_order=2, n_splines=20, lam=0.6), name="GAM") .. GENERATED FROM PYTHON SOURCE LINES 21-22 Evaluate predictive performance .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: default exp.model_diagnose(model="GAM", show="accuracy_table") .. rst-class:: sphx-glr-script-out .. code-block:: none ACC AUC F1 LogLoss Brier Train 0.8363 0.9226 0.8387 0.3512 0.1130 Test 0.8475 0.9306 0.8432 0.3406 0.1062 Gap 0.0112 0.0080 0.0045 -0.0105 -0.0068 .. GENERATED FROM PYTHON SOURCE LINES 25-26 Global interpretation: effect plot for X0 .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: default exp.model_interpret(model="GAM", show="global_effect_plot", uni_feature="X0", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_001.png :alt: X0 (50.3%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 30-31 Global interpretation: effect plot for X1 .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: default exp.model_interpret(model="GAM", show="global_effect_plot", uni_feature="X1", original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_002.png :alt: X1 (49.7%) :srcset: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-36 Global interpretation: feature importance .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: default exp.model_interpret(model="GAM", show="global_fi", figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_003.png :alt: Feature Importance :srcset: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 Local interpretation .. GENERATED FROM PYTHON SOURCE LINES 40-41 .. code-block:: default exp.model_interpret(model="GAM", show="local_fi", sample_id=0, original_scale=True, figsize=(5, 4)) .. image-sg:: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_004.png :alt: Predicted: 0.2469 | Actual: 1.0000 :srcset: /auto_examples/3_models/images/sphx_glr_plot_1_gam_cls_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 5.861 seconds) **Estimated memory usage:** 12 MB .. _sphx_glr_download_auto_examples_3_models_plot_1_gam_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_1_gam_cls.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_1_gam_cls.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_1_gam_cls.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_