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
frameis a data framexvarandtruthvarare strings naming the prediction and actual outcome columns offrametitleis 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.
Cet exercice fait partie du cours
Supervised Learning in R: Regression
Instructions
- Load the package
WVPlotsusinglibrary(). - Plot the gain curve. Give the plot the title "Unemployment model". Do the model's predictions sort correctly?
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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")