MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Support Vector Machines in R

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

#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)
Edit dan Jalankan Kode