An example showing the plot_cumulative_gain method

In this example, we'll be plotting a cumulative gain curve to describe the classification performance of a LogisticRegression classifier using the breast cncer dataset from scikit-learn. Here, we'll be using the scikitplot.metrics.plot_cumulative_gain method. A cumulative gain plot is a method of evaluating the effectiveness of a classification model by visualising the gain in true positives for a given fraction of the total population targeted by the classifier


In [9]:
%matplotlib inline
"""
An example showing the plot_cumulative_gain method used
by a scikit-learn classifier
"""
from __future__ import absolute_import
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_breast_cancer as load_data
# Import scikit-plot
import scikitplot as skplt

In [10]:
# Load the data
X, y = load_data(return_X_y=True)

# Create an instance of the LogisticRegression
lr = LogisticRegression()

# Perform predictions
lr.fit(X, y)
probas = lr.predict_proba(X)

In [11]:
# Plot!
skplt.metrics.plot_cumulative_gain(y_true=y, y_probas=probas)
plt.show()