The gain curve to evaluate the unemployment model
In the previous exercise you made predictions about female_unemployment
and visualized the predictions and the residuals.
Now, you will also plot the gain curve of the unemployment_model
's predictions against actual female_unemployment
using the WVPlots::GainCurvePlot()
(docs) function.
For situations where order is more important than exact values, the gain curve helps you check if the model's predictions sort in the same order as the true outcome.
Calls to the function GainCurvePlot()
look like:
GainCurvePlot(frame, xvar, truthvar, title)
where
frame
is a data framexvar
andtruthvar
are strings naming the prediction and actual outcome columns offrame
title
is the title of the plot
When the predictions sort in exactly the same order, the relative Gini coefficient is 1. When the model sorts poorly, the relative Gini coefficient is close to zero, or even negative.
The data frame unemployment
, which also contains the predictions, and the model unemployment_model
are available for you to use.
This exercise is part of the course
Supervised Learning in R: Regression
Exercise instructions
- Load the package
WVPlots
usinglibrary()
. - Plot the gain curve. Give the plot the title "Unemployment model". Do the model's predictions sort correctly?
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# unemployment (with predictions) is available
summary(unemployment)
# unemployment_model is available
summary(unemployment_model)
# Load the package WVPlots
___
# Plot the Gain Curve
___(___, ___, ___, "Unemployment model")