BaşlayınÜcretsiz Başlayın

SVM with polynomial kernel

In this exercise you will build a SVM with a quadratic kernel (polynomial of degree 2) for the radially separable dataset you created earlier in this chapter. You will then calculate the training and test accuracies and create a plot of the model using the built in plot() function. The training and test datasets are available in the dataframes trainset and testset, and the e1071 library has been preloaded.

Bu egzersiz

Support Vector Machines in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Build SVM model on the training data using a polynomial kernel of degree 2.
  • Calculate training and test accuracy for the given training/test partition.
  • Plot the model against the training data.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

svm_model<- 
    svm(y ~ ., data = trainset, type = "C-classification", 
        kernel = ___, degree = ___)

#measure training and test accuracy
pred_train <- predict(svm_model, ___)
mean(pred_train == ___$y)
pred_test <- predict(svm_model, ___)
mean(pred_test == ___$y)

#plot
plot(___, trainset)
Kodu Düzenle ve Çalıştır