October 2017
Beginner to intermediate
572 pages
26h 1m
English
Perform the following steps to cross-validate the telecom churn dataset:
> ind = cut(1:nrow(churnTrain), breaks=10, labels=F)
> accuracies = c()
> for (i in 1:10) {+ fit = svm(churn ~., churnTrain[ind != i,])
+ predictions = predict(fit, churnTrain[ind == i, ! names(churnTrain) %in% c("churn")])
+ correct_count = sum(predictions == churnTrain[ind == i,c("churn")])
+ accuracies = append(correct_count / nrow(churnTrain[ind == i,]), accuracies)
+ }
> accuracies
Output
[1] 0.9341317 0.8948949 0.8978979 0.9459459 0.9219219 0.9281437 0.9219219 0.9249249 ...Read now
Unlock full access