First of all, sorry about my english, I am brazilian and I am improving it yet.
I am using RWeka
to create classification models (NaiveBayes, JRip, J48, SVM) and I need the probabilities of each instance.
For SVM (package "e1041") I simply do
model<-svm(classification~.,data=treino1, probability=TRUE)
pred <- predict(model, teste1[,-ncol(teste1)], probability = TRUE)
prob<-attr(pred, "probabilities")
And, then, the output is something like:
0 1
1 9.126349e-01 0.087365132
2 9.085960e-01 0.091404044
3 9.414368e-01 0.058563209
What should I do to obtain the same type of output with J48 (package "RWeka")?
model<-J48(classification~.,data=treino1, probability=TRUE)
Error in J48(classification ~ ., data = treino1, probability = TRUE) : unused argument (probability = TRUE)
Thanks!
You should specify type = 'probability
. Here's an example using the iris
dataset:
require(RWeka)
fit = J48(Species~., data=iris)
pred = predict(fit, iris, type = 'probability')
tail(p)
setosa versicolor virginica
145 0 0.02173913 0.9782609
146 0 0.02173913 0.9782609
147 0 0.02173913 0.9782609
148 0 0.02173913 0.9782609
149 0 0.02173913 0.9782609
150 0 0.02173913 0.9782609