Performance of evolution variables
Given is a basetable
that has 3 regular predictive variables, namely "gender_F", "age", "donations_2017", and an evolution variable "donations_2017_min_2016" that contains the number of donations made in 2017 minus the number of donations made in 2016.
In this exercise you will see the added value of using evolution variables. You will construct two predictive models, one using the regular predictive variables given for you in variables_regular
and one replacing "donations_2017" by "donations_2017_min_2016", these variables are given for you in variables_evolution
. The logistic regression model is already initialized for you in logreg
. The model using the regular variables has already been implemented, the AUC is in auc_regular
.
This exercise is part of the course
Intermediate Predictive Analytics in Python
Exercise instructions
- Select the evolution variables in
X_evolution
and fit the model. - Make predictions using
.predict_proba()
using this model for all observations inX_evolution
and calculate the AUC withroc_auc_score()
. - Print the AUCs of both models and compare.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Select the evolution variables and fit the model
X_evolution = ____[____]
logreg.fit(____, y)
# Make predictions and calculate the AUC
predictions_evolution = logreg.____(____)[:,1]
auc_evolution = ____(____, ____)
# Print the respective AUC values
print(round(auc_regular, 2))
____(round(____, 2))