Rで学ぶSupport Vector Machines
Kailash Awati
Instructor

ggplot() を使って $X_1 - X_2$ 空間にデータセットをプロットp <- ggplot(data = df4, aes(x = x1sq, y = x2sq, color = y)) +
geom_point() +
scale_color_manual(values = c("red", "blue")) +
geom_abline(slope = -1, intercept = 0.49)
p

(gamma * (u.v) + coef0) ^ degreedegree は多項式の次数gamma と coef0 はチューニングパラメータu、v はデータセットに属するベクトル(データ点)degree = 2 を設定cost、gamma、coef0 のデフォルト値を使用(1、1/2、0)svm_model <- svm(y ~ ., data = trainset, type = "C-classification", kernel = "polynomial", degree = 2)
# Predictions
pred_test <- predict(svm_model, testset)
mean(pred_test == testset$y)
0.9354839
# Visualize model
plot(svm_model, trainset)

Rで学ぶSupport Vector Machines