MulaiMulai sekarang secara gratis

Building a more sophisticated model

One of the best predictors of future giving is a history of recent, frequent, and large gifts. In marketing terms, this is known as R/F/M:

  • Recency
  • Frequency
  • Money

Donors that haven't given both recently and frequently may be especially likely to give again; in other words, the combined impact of recency and frequency may be greater than the sum of the separate effects.

Because these predictors together have a greater impact on the dependent variable, their joint effect must be modeled as an interaction. The donors dataset has been loaded for you.

Latihan ini adalah bagian dari kursus

Supervised Learning in R: Classification

Lihat Kursus

Petunjuk latihan

  • Create a logistic regression model of donated as a function of money plus the interaction of recency and frequency. Use * to add the interaction term.
  • Examine the model's summary() to confirm the interaction effect was added.
  • Save the model's predicted probabilities as rfm_prob. Use the predict() function, and remember to set the type argument.
  • Plot a ROC curve by using the function roc(). Remember, this function takes the column of outcomes and the vector of predictions.
  • Compute the AUC for the new model with the function auc() and compare performance to the simpler model.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Build a recency, frequency, and money (RFM) model
rfm_model <- ___

# Summarize the RFM model to see how the parameters were coded


# Compute predicted probabilities for the RFM model
rfm_prob <- ___

# Plot the ROC curve and find AUC for the new model
library(pROC)
ROC <- ___
plot(___, col = "red")
auc(___)
Edit dan Jalankan Kode