.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/kds/plot_report_script.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 JupyterLite or Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_kds_plot_report_script.py: plot_report with examples ================================== An example showing the :py:func:`~scikitplot.kds.report` function used by a scikit-learn classifier. .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python :lineno-start: 9 # Authors: The scikit-plots developers # SPDX-License-Identifier: BSD-3-Clause .. GENERATED FROM PYTHON SOURCE LINES 13-38 .. code-block:: Python :lineno-start: 13 from sklearn.datasets import ( load_breast_cancer as data_2_classes, # load_iris as data_3_classes, ) from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split # importing pylab or pyplot import matplotlib.pyplot as plt import numpy as np; np.random.seed(0) # reproducibility # Import scikit-plot import scikitplot as sp # Load the data X, y = data_2_classes(return_X_y=True, as_frame=False) X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.5, random_state=0) # Create an instance of the LogisticRegression model = LogisticRegression(max_iter=int(1e5), random_state=0).fit(X_train, y_train) # Perform predictions y_val_prob = model.predict_proba(X_val) .. GENERATED FROM PYTHON SOURCE LINES 39-51 .. code-block:: Python :lineno-start: 39 sp.kds.decile_table( y_val, y_val_prob, save_fig=True, save_fig_filename="", # overwrite=True, add_timestamp=True, # verbose=True, display_term_tables=True, ) .. rst-class:: sphx-glr-script-out .. code-block:: none LABELS INFO: prob_min : Minimum probability in a particular decile prob_max : Minimum probability in a particular decile prob_avg : Average probability in a particular decile cnt_events : Count of events in a particular decile cnt_resp : Count of responders in a particular decile cnt_non_resp : Count of non-responders in a particular decile cnt_resp_rndm : Count of responders if events assigned randomly in a particular decile cnt_resp_wiz : Count of best possible responders in a particular decile resp_rate : Response Rate in a particular decile [(cnt_resp/cnt_cust)*100] cum_events : Cumulative sum of events decile-wise cum_resp : Cumulative sum of responders decile-wise cum_resp_wiz : Cumulative sum of best possible responders decile-wise cum_non_resp : Cumulative sum of non-responders decile-wise cum_events_pct : Cumulative sum of percentages of events decile-wise cum_resp_pct : Cumulative sum of percentages of responders decile-wise cum_resp_pct_wiz : Cumulative sum of percentages of best possible responders decile-wise cum_non_resp_pct : Cumulative sum of percentages of non-responders decile-wise KS : KS Statistic decile-wise lift : Cumuative Lift Value decile-wise .. raw:: html
decile prob_min prob_max prob_avg cnt_cust cnt_resp cnt_non_resp cnt_resp_rndm cnt_resp_wiz resp_rate cum_cust cum_resp cum_resp_wiz cum_non_resp cum_cust_pct cum_resp_pct cum_resp_pct_wiz cum_non_resp_pct KS lift
0 1 1.000 1.000 1.000 29.0 29.0 0.0 18.4 29 100.000 29.0 29.0 29 0.0 10.175 15.761 15.761 0.000 15.761 1.549
1 2 0.999 1.000 1.000 28.0 28.0 0.0 18.4 28 100.000 57.0 57.0 57 0.0 20.000 30.978 30.978 0.000 30.978 1.549
2 3 0.998 0.999 0.999 29.0 29.0 0.0 18.4 29 100.000 86.0 86.0 86 0.0 30.175 46.739 46.739 0.000 46.739 1.549
3 4 0.993 0.997 0.996 28.0 28.0 0.0 18.4 28 100.000 114.0 114.0 114 0.0 40.000 61.957 61.957 0.000 61.957 1.549
4 5 0.960 0.992 0.980 29.0 29.0 0.0 18.4 29 100.000 143.0 143.0 143 0.0 50.175 77.717 77.717 0.000 77.717 1.549
5 6 0.772 0.956 0.888 28.0 25.0 3.0 18.4 28 89.286 171.0 168.0 171 3.0 60.000 91.304 92.935 2.970 88.334 1.522
6 7 0.066 0.769 0.346 29.0 16.0 13.0 18.4 13 55.172 200.0 184.0 184 16.0 70.175 100.000 100.000 15.842 84.158 1.425
7 8 0.000 0.048 0.011 28.0 0.0 28.0 18.4 0 0.000 228.0 184.0 184 44.0 80.000 100.000 100.000 43.564 56.436 1.250
8 9 0.000 0.000 0.000 29.0 0.0 29.0 18.4 0 0.000 257.0 184.0 184 73.0 90.175 100.000 100.000 72.277 27.723 1.109
9 10 0.000 0.000 0.000 28.0 0.0 28.0 18.4 0 0.000 285.0 184.0 184 101.0 100.000 100.000 100.000 100.000 0.000 1.000


.. GENERATED FROM PYTHON SOURCE LINES 52-53 Plot! .. GENERATED FROM PYTHON SOURCE LINES 53-64 .. code-block:: Python :lineno-start: 53 ax = sp.kds.report( y_val, y_val_prob, save_fig=True, save_fig_filename="", # overwrite=True, add_timestamp=True, # verbose=True, display_term_tables=True, ) .. image-sg:: /auto_examples/kds/images/sphx_glr_plot_report_script_001.png :alt: KS Statistic Plot :srcset: /auto_examples/kds/images/sphx_glr_plot_report_script_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none LABELS INFO: prob_min : Minimum probability in a particular decile prob_max : Minimum probability in a particular decile prob_avg : Average probability in a particular decile cnt_events : Count of events in a particular decile cnt_resp : Count of responders in a particular decile cnt_non_resp : Count of non-responders in a particular decile cnt_resp_rndm : Count of responders if events assigned randomly in a particular decile cnt_resp_wiz : Count of best possible responders in a particular decile resp_rate : Response Rate in a particular decile [(cnt_resp/cnt_cust)*100] cum_events : Cumulative sum of events decile-wise cum_resp : Cumulative sum of responders decile-wise cum_resp_wiz : Cumulative sum of best possible responders decile-wise cum_non_resp : Cumulative sum of non-responders decile-wise cum_events_pct : Cumulative sum of percentages of events decile-wise cum_resp_pct : Cumulative sum of percentages of responders decile-wise cum_resp_pct_wiz : Cumulative sum of percentages of best possible responders decile-wise cum_non_resp_pct : Cumulative sum of percentages of non-responders decile-wise KS : KS Statistic decile-wise lift : Cumuative Lift Value decile-wise .. GENERATED FROM PYTHON SOURCE LINES 65-73 .. tags:: model-type: classification model-workflow: model evaluation plot-type: line plot-type: cum-gain curve level: beginner purpose: showcase .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.265 seconds) .. _sphx_glr_download_auto_examples_kds_plot_report_script.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/scikit-plots/scikit-plots/maintenance/0.4.X?urlpath=lab/tree/notebooks/auto_examples/kds/plot_report_script.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/kds/plot_report_script.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_report_script.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_report_script.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_report_script.zip ` .. include:: plot_report_script.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_