Get Started

Constructing the cumulative gains curve

The cumulative gains curve is an evaluation curve that assesses the performance of your model. It shows the percentage of targets reached when considering a certain percentage of your population with the highest probability to be target according to your model.

To construct this curve, you can use the .plot_cumulative_gain() method in the scikitplot module and the matplotlib.pyplot module. As for each model evaluation metric or curve, you need the true target values on the one hand and the predictions on the other hand to construct the cumulative gains curve.

This is a part of the course

“Introduction to Predictive Analytics in Python”

View Course

Exercise instructions

  • Import the matplotlib.pyplot module.
  • Import the scikitplot module.
  • Construct the cumulative gains curve, given that the model outputs the values in predictions_test and the true target values are in targets_test.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the matplotlib.pyplot module 
import ____.____ as plt

# Import the scikitplot module
import ____ as skplt

# Plot the cumulative gains graph
skplt.metrics.____(targets_test, ____)
plt.show()
Edit and Run Code

This exercise is part of the course

Introduction to Predictive Analytics in Python

BeginnerSkill Level
5.0+
3 reviews

In this course you'll learn to use and present logistic regression models for making predictions.

Now that you know how to build a good model, you should convince stakeholders to use it by creating appropriate graphs. You will learn how to construct and interpret the cumulative gains curve and lift graph.

Exercise 1: The cumulative gains curveExercise 2: Interpreting the cumulative gains curveExercise 3: Constructing the cumulative gains curve
Exercise 4: A random modelExercise 5: The lift curveExercise 6: Interpreting the lift curveExercise 7: Constructing the lift curveExercise 8: A perfect modelExercise 9: Guiding business to better decisionsExercise 10: Targeting using cumulative gains curveExercise 11: Business case using lift curveExercise 12: Business case using cumulative gains curve

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free