मल्टीक्लास समस्याएँ

R में Support Vector Machines

Kailash Awati

Instructor

iris डेटासेट - परिचय

  • 5 गुणों के 150 माप
    • Petal width और length - number (predictor variables)
    • Sepal width और length - number (predictor variables)
    • Species - category: setosa, virginica या versicolor (predicted variable)
  • डेटासेट UCI ML repository से उपलब्ध
R में Support Vector Machines

iris डेटासेट का विज़ुअलाइज़ेशन

  • petal length बनाम petal width का प्लॉट करें.
library(ggplot2)

# Plot petal length vs width for dataset, distinguish species by color
p <- ggplot(data = iris,
            aes(x = Petal.Width,
                y = Petal.Length,
                color = Species)) +
     geom_point()

# Display plot
p
R में Support Vector Machines

अध्याय 2.4 - iris डेटासेट: petal length बनाम petal width, species रंग से अलग दिखे

R में Support Vector Machines

SVM एल्गोरिदम मल्टीक्लास समस्याओं को कैसे संभालता है?

  • SVMs मूलतः बाइनरी क्लासिफायर होते हैं.
  • इन्हें निम्न वोटिंग रणनीति से मल्टीक्लास समस्याओं पर लागू कर सकते हैं:
    • डेटा को ऐसे सबसेट्स में बाँटें जिनमें हर बार दो क्लास हों.
    • हर सबसेट के लिए बाइनरी क्लासिफिकेशन समस्या हल करें.
    • प्रत्येक डेटा पॉइंट को क्लास देने के लिए मेजॉरिटी वोट लें.
  • इसे one-against-one क्लासिफिकेशन रणनीति कहते हैं.
R में Support Vector Machines

मल्टीक्लास linear SVM बनाना

  • iris डेटासेट के लिए एक linear SVM बनाएँ
    • 80/20 training/test split (seed 10), default cost
library(e1071)

# Build model
svm_model <- svm(Species ~ ., 
                data = trainset, 
                type = "C-classification", 
                kernel = "linear")
  • accuracy निकालें
pred_train <- predict(svm_model, trainset)
mean(pred_train == trainset$Species)
0.9756098
pred_test <- predict(svm_model, testset)
mean(pred_test == testset$Species)
0.962963
R में Support Vector Machines

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

R में Support Vector Machines

Preparing Video For Download...