Description
We've explored a number of algorithms before, each of which has pros and cons, so when we decide which algorithm to choose for specific problems, we have to reevaluate the different predictive models. To simplify this process, we use the caret package to generate and compare different models and performance. Operation
Load the corresponding package and set the training control algorithm to 10 percent cross-validation with a repeat Count of 3:
Library (ROCR) library (e1071) library ("
PROC") library (
caret)
library ("PROC")
control = Traincontrol (method = "REPAETEDCV", number
= ten,
repeats =3,
classprobs = TRUE,
summaryfunction = Twoclasssummary)
Use GLM to train a classifier on a training data set
Glm.model = Train (churn ~.,
data= trainset,
method = "GLM",
metric = "ROC",
Trcontrol = control)
Train a classifier on a training data set using SVM
Svm.model = Train (churn ~.,
data= trainset,
method = "Svmradial",
metric = "ROC",
Trcontrol = control)
Use the Rpart function to see how Rpart works on the training data set
Rpart.model = Train (churn ~.,
data = trainset,
method = "Svmradial",
metric = "ROC",
Trcontrol = control)
Use different well-trained data to classify predictions: