I am working on the project handwritten pattern recognition(Alphabets) using Support Vector Machines. I have 26 classes in total but I am not able to classi
For a multi class classifier, you can get probabilities for each class. You can set 'probability = TRUE' while training the model & in 'predict' api. This will give you the probabilities of each class. Below is the sample code for iris data set:
data(iris)
attach(iris)
x <- subset(iris, select = -Species)
y <- Species
model <- svm(x, y, probability = TRUE)
pred_prob <- predict(model, x, decision.values = TRUE, probability = TRUE)
With above code, 'pred_prob' will have probabilities among other data. You can access only probabilities in the object with below statement:
attr(pred_prob, "probabilities")
setosa versicolor virginica
1 0.979989881 0.011347796 0.008662323
2 0.972567961 0.018145783 0.009286256
3 0.978668604 0.011973933 0.009357463
...
Hope this helps.
NOTE: I believe when you give 'probability' internally svm performs one vs rest classifier because, it takes lot more time with 'probability' param set against the model with 'probability' param not being set.