LoslegenKostenlos loslegen

In-sample fit full model

It is coding time again, which means coming back to the exercise dataset defaultData.

You now want to know how your model performs by calculating the accuracy. In order to do so, you first need a confusion matrix.

Take the logitModelFull, first. The model is already specified and lives in your environment.

Diese Übung ist Teil des Kurses

Machine Learning for Marketing Analytics in R

Kurs anzeigen

Anleitung zur Übung

  • Use predict() to receive a probability of each customer defaulting on their payment.
  • In order to construct the confusion matrix use the function confusion.matrix() from SDMTools. Note that SDMTools cannot be downloaded from CRAN anymore. So if you want to practice at your home computer you can install the package by using remotes::install_version("SDMTools", "1.1-221.2") which will install the version of SDMTools that is used at this course.
  • Choose a common threshold of 0.5.
  • Calculate the accuracy using the confusion matrix.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Make predictions using the full Model
defaultData$predFull <- predict(logitModelFull, type = ___, na.action = ___)

# Construct the in-sample confusion matrix
confMatrixModelFull <- confusion.matrix(defaultData$___,defaultData$___, threshold = ___)
confMatrixModelFull

# Calculate the accuracy for the full Model
accuracyFull <- sum(diag(___)) / ___(___)
accuracyFull
Code bearbeiten und ausführen