SVMs को ट्यून करना

R में Support Vector Machines

Kailash Awati

Instructor

ट्यूनिंग का उद्देश्य

  • जटिल kernels के लिए parameters के सर्वोत्तम मान हाथ से खोजना कठिन है.
  • Objective: tune.svm() फंक्शन से parameters का सर्वोत्तम सेट खोजना.
R में Support Vector Machines

ट्यूनिंग संक्षेप में

  • कैसे काम करता है:
    • हर parameter के लिए search values की एक रेंज सेट करें. उदाहरण: cost = 10^(-1:3), gamma = c(0.1,1,10), coef0 = c(0.1,1,10)
    • हर संभव parameter-कॉम्बिनेशन पर एक SVM मॉडल बनाएँ और accuracy का आकलन करें.
    • वह कॉम्बिनेशन लौटाएँ जो सबसे अच्छी accuracy दे.
  • यह प्रक्रिया कंप्यूटेशनली भारी है!
R में Support Vector Machines
  • पहले बनाए गए radially separable डेटासेट पर SVM मॉडल ट्यून करें
    • पिछली लेसन में polynomial kernel SVM बनाया था
    • SVM की accuracy ~94% थी.
  • क्या gamma, cost और coef0 ट्यून करके और बेहतर कर सकते हैं?
tune_out <- tune.svm(x = trainset[,-3], y = trainset[,3], 
                     type = "C-classification", kernel = "polynomial", degree = 2,
                     cost = 10^(-1:2), gamma = c(0.1,1,10), coef0 = c(0.1,1,10))

#print out tuned parameters tune_out$best.parameters$cost tune_out$best.parameters$gamma tune_out$best.parameters$coef0
0.1
10
1
R में Support Vector Machines
  • tune.svm() से मिले सर्वोत्तम parameter मानों से SVM मॉडल बनाएँ.
svm_model <- svm(y ~ ., data = trainset, type = "C-classification", kernel = "polynomial", degree = 2,
        cost = tune_out$best.parameters$cost,
        gamma = tune_out$best.parameters$gamma,
        coef0 = tune_out$best.parameters$coef0)
  • training और test accuracy का मूल्यांकन करें
pred_train <- predict(svm_model, trainset)
mean(pred_train == trainset$y)
pred_test <- predict(svm_model, testset)
mean(pred_test == testset$y)
1

0.9677419
#plot using svm plot
plot(svm_model, trainset)
R में Support Vector Machines

अध्याय 3.4 - radially separable डेटासेट, ट्यून किया हुआ quadratic kernel, svm.plot से प्लॉट

R में Support Vector Machines

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

R में Support Vector Machines

Preparing Video For Download...