開始使用免費開始

使用 `plot()` 視覺化決策與邊界範圍

在這個練習中,你會重新建立 SVM 模型(複習用),並使用內建的 SVM plot() 函式來視覺化決策區域與支援向量。訓練資料已在資料框 trainset 中提供。

本練習屬於課程

R 的支援向量機

檢視課程

練習說明

  • 載入建立 SVM 模型所需的函式庫。
  • 使用訓練資料建立線性 SVM 模型。
  • 繪製決策區域與支援向量。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

#load required library
library(___)

#build svm model
svm_model<- 
    svm(y ~ ., data = ___, type = "C-classification", 
        kernel = "___", scale = FALSE)

#plot decision boundaries and support vectors for the training data
plot(x = svm_model, data = ___)
編輯並執行程式碼