Explore Courses Blog Tutorials Interview Questions
0 votes
in Machine Learning by (19k points)

I just created a model using scikit-learn which estimates the probability of how likely a client will respond to some offer. Now I'm trying to evaluate my model. For that I want to plot the lift chart. I understand the concept of lift, but I'm struggling to understand how to actually implement it in python.

1 Answer

0 votes
by (33.1k points)

You can use the scikit-plot package to do the heavy lifting.

skplt.metrics.plot_cumulative_gain(y_test, predicted_probas)

For example:

from sklearn.datasets import load_breast_cancer

from sklearn.model_selection import train_test_split

from sklearn.naive_bayes import GaussianNB

X, y = load_breast_cancer(return_X_y=True)

X_train, X_test, y_train, y_test = train_test_split(X, y, 


nb = GaussianNB(), y_train)

predicted_probas = nb.predict_proba(X_test)

# The magic happens here

import matplotlib.pyplot as plt

import scikitplot as skplt

skplt.metrics.plot_cumulative_gain(y_test, predicted_probas)


enter image description here

Hope this answer helps you!

For more details, go through Python Course.

Browse Categories