how to use multisvm

조회 수: 4 (최근 30일)
shafna mtp
shafna mtp 2017년 3월 1일
답변: Purvaja 2025년 2월 3일
i want to use svm classifier for 4 class classification, and want to know how can i use svm for multiclass

답변 (1개)

Purvaja
Purvaja 2025년 2월 3일
I see that you wish to classify multiple classes using SVM. We can achieve this using “ClassificationECOC” function. You can perform the following steps:
  • Assume some data with 4 classes for prediction
  • Combine the classes into a single dataset
data = [class1; class2; class3; class4];
X = data(:, 1:2); % Features
Y = data(:, 3); % Labels
  • Train the SVM model using fitcecoc
svmModel = fitcecoc(X, Y);
  • Display the trained model
disp(svmModel);
  • Make predictions on the training data
predictions = predict(svmModel, X);
  • Calculate accuracy
accuracy = sum(predictions == Y) / length(Y) * 100;
fprintf('Accuracy: %.2f%%\n', accuracy);
  • Get predictions for some points
Predictions = predict(svmModel, Points);
You can check another example by simply typing this command in your MATLAB command window:
openExample('stats/TrainAnECOCClassifierUsingSVMLearnersExample')
For more clarification details on the functions used, you can refer “ClassificationECOC”, check out the following in documentation:
Hope this helps you!!

카테고리

Help CenterFile Exchange에서 Discriminant Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by