R language using caret package to compare ROC curves

Source: Internet
Author: User
Tags svm
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.