For a classification problem I am giving the R package kernlab a shot – not the least because it offers to calculate class probabilities instead of only a plain decision. However, comparing results for both options appears to be contradictory. Some code for a 4 elemented testing data set:
model <- ksvm(x=formula,data=data[trainIndex,],
prob.model=TRUE, type="C-svc");
predProb <- predict(model,data[testIndex,],type="probabilities");
predClass <- predict(model,data[testIndex,]);
In my 4 class case this led to:
> predProb
desmino filamino myotilino titino
[1,] 0.06676130 0.03833511 0.08397281 0.81093078
[2,] 0.06832143 0.83437244 0.03403721 0.06326892
[3,] 0.03655672 0.02404717 0.05114122 0.88825489
[4,] 0.03305530 0.05722160 0.68772201 0.22200108
> predClass
[1] myotilino filamino titino myotilino
Levels: desmino filamino myotilino titino
I am disturbed by the first line in the matrix. Clearly the probability attached to titino
accounts for for the highest value. Still myotilino
won in terms of predicted class. Is this a bug, or is there something I did not understand?