plot_report with examples#
An example showing the report
function used
by a scikit-learn classifier.
9 # Authors: The scikit-plots developers
10 # SPDX-License-Identifier: BSD-3-Clause
13 from sklearn.datasets import (
14 load_breast_cancer as data_2_classes,
15 # load_iris as data_3_classes,
16 )
17 from sklearn.linear_model import LogisticRegression
18 from sklearn.model_selection import train_test_split
19
20 # importing pylab or pyplot
21 import matplotlib.pyplot as plt
22 import numpy as np; np.random.seed(0) # reproducibility
23
24 # Import scikit-plot
25 import scikitplot as sp
26
27 # Load the data
28 X, y = data_2_classes(return_X_y=True, as_frame=False)
29 X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.5, random_state=0)
30
31 # Create an instance of the LogisticRegression
32 model = LogisticRegression(max_iter=int(1e5), random_state=0).fit(X_train, y_train)
33
34 # Perform predictions
35 y_val_prob = model.predict_proba(X_val)
39 sp.kds.decile_table(
40 y_val,
41 y_val_prob,
42 save_fig=True,
43 save_fig_filename="",
44 # overwrite=True,
45 add_timestamp=True,
46 # verbose=True,
47 display_term_tables=True,
48 )
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
Plot!
53 ax = sp.kds.report(
54 y_val,
55 y_val_prob,
56 save_fig=True,
57 save_fig_filename="",
58 # overwrite=True,
59 add_timestamp=True,
60 # verbose=True,
61 display_term_tables=True,
62 )

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
Total running time of the script: (0 minutes 1.265 seconds)
Related examples