Linear SVM for a radially separable dataset
In this exercise you will build two linear SVMs, one for cost = 1 (default) and the other for cost = 100, for the radially separable dataset you created in the first lesson of this chapter. You will also calculate the training and test accuracies for both costs. The e1071 library has been loaded, and test and training datasets have been created for you and are available in the data frames trainset and testset.
Este exercicio faz parte do curso
Support Vector Machines in R
exercicio interativo prático
Tente este exercicio completando este código de exemplo.
#default cost mode;
svm_model_1 <- svm(y ~ ., data = ___, type = "C-classification", cost = ___, kernel = "linear")
#training accuracy
pred_train <- predict(svm_model_1, ___)
mean(pred_train == ___$y)
#test accuracy
pred_test <- predict(svm_model_1, ___)
mean(pred_test == ___$y)