LoslegenKostenlos loslegen

Subsetting

Remember, the company wants to expand their business and offer Hoppiness nationwide. Therefore, the model should also work on data obtained from new stores. One possibility to check how your model will perform on new data is to first train your model on one part of the data and then try to predict the remaining part of the data.

You create a trainings data set by withholding the last purchase that was recorded for each customer. You can do this by using the function subset() on choice.data and selecting all observations with indicator variable LASTPURCHASE to equal 0. Likewise, you create a test data set by selecting all observations with indicator variable LASTPURCHASE to equal 1.

Diese Übung ist Teil des Kurses

Building Response Models in R

Kurs anzeigen

Anleitung zur Übung

  • Leave out the last purchase to create a training data set. Use the function subset() on choice.data. Specify LASTPURCHASE == 0 as subset argument. Assign the result to train.data.
  • Create a test data set by using the function subset() on choice.data. Specify LASTPURCHASE == 1 as subset argument. Assign the result to test.data.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Create the training data


# Create the test data
Code bearbeiten und ausführen