March 2019
Beginner to intermediate
464 pages
10h 57m
English
Similar to the previous chapter, we are going to split the sample set into train and test sets using the following code:
# train/test set splitlibrary(caTools)sample <- sample.split(sampleDF$CustomerID, SplitRatio = .8)train <- as.data.frame(subset(sampleDF, sample == TRUE))[,-1]test <- as.data.frame(subset(sampleDF, sample == FALSE))[,-1]
As you can see from this code, we are taking 80% of the sample set for training the model and the remaining 20% for testing and evaluating the model performance. In this section, we will be using a linear regression model. However, we recommend experimenting with other machine learning algorithms, such as random forest and support vector machine (SVM). You can train a random forest model ...
Read now
Unlock full access