CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Support Vector Machines in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

#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)
Modifier et exécuter le code