Session Ready
Exercise

Probabilities

There are four main ways of expressing the prediction from a logistic regression model – we'll look at each of them over the next four exercises. Firstly, since the response variable is either "yes" or "no", you can make a prediction of the probability of a "yes". Here, you'll calculate and visualize these probabilities.

Two variables are available:

  • mdl_churn_vs_relationship is the fitted logistic regression model of has_churned versus time_since_first_purchase.
  • explanatory_data is a DataFrame of explanatory values.
Instructions 1/2
undefined XP
  • 1
  • 2
  • Create a DataFrame, prediction_data, by assigning a column has_churned to explanatory_data.
  • In the has_churned column, store the predictions of the probability of churning: use the model, mdl_churn_vs_relationship, and the explanatory data, explanatory_data.
  • Print the first five lines of the prediction DataFrame.