RBF Kernel

R में Support Vector Machines

Kailash Awati

Instructor

संक्षेप में RBF Kernel

  • डेटासेट में दो बिंदुओं के बीच दूरी का घटता फंक्शन।
  • k-NN एल्गोरिदम का अनुकरण करता है।
R में Support Vector Machines

अध्याय 4.3 - RBF kernel - बिंदुओं की दूरी के साथ प्रभाव

R में Support Vector Machines

RBF kernel के साथ SVM बनाना

  • जटिल डेटासेट पर RBF kernel SVM बनाएँ
svm_model <- svm(y ~ ., 
                data = trainset, 
                type = "C-classification",
                kernel = "radial")
  • प्रशिक्षण/टेस्ट एक्यूरेसी निकालें और प्रशिक्षण डेटासेट पर प्लॉट करें।
pred_train <- predict(svm_model, trainset)
mean(pred_train == trainset$y)
0.93125
pred_test <- predict(svm_model, testset)
mean(pred_test == testset$y)
0.9416667
#plot decision boundary
plot(svm_model, trainset)
R में Support Vector Machines

अध्याय 4.3 - जटिल डेटासेट, डिफॉल्ट RBF kernel, svm.plot से प्लॉट

R में Support Vector Machines

डिसीजन बाउंडरी को और बेहतर करना

  • tune.svm() से gamma और cost ट्यून करें
# Tune parameters
tune_out <- tune.svm(x = trainset[,-3],
                     y = trainset[,3],
                     gamma = 5 * 10 ^ (-2:2),
                     cost = c(0.01, 0.1, 1, 10, 100),
                     type = "C-classification",
                     kernel = "radial")
  • सर्वोत्तम पैरामीटर प्रिंट करें
# Print best values of cost and gamma
tune_out$best.parameters$cost
1
tune_out$best.parameters$gamma
5
R में Support Vector Machines

ट्यून किया गया मॉडल

  • best.parameters से ट्यून किया मॉडल बनाएँ
svm_model <- svm(y ~ ., data = trainset, 
              type = "C-classification", 
              kernel = "radial",
              cost = tune_out$best.parameters$cost,
              gamma = tune_out$best.parameters$gamma)
  • टेस्ट एक्यूरेसी निकालें
mean(pred_test == testset$y)
0.95
  • डिसीजन बाउंडरी प्लॉट करें
plot(svm_model, trainset)
R में Support Vector Machines

अध्याय 4.3 - जटिल डेटासेट, ट्यून किया RBF kernel, svm.plot से प्लॉट

R में Support Vector Machines

अभ्यास करते हैं!

R में Support Vector Machines

Preparing Video For Download...