[R] repeated execution of svm(e1071) gives different results, if probability = TRUE is set
Juergen Rose
rose at rz.uni-potsdam.de
Wed Feb 23 18:12:57 CET 2011
I called svm and predict three times with the same data and got three
differing predictions:
> library(e1071)
Lade nötiges Paket: class
> data(Glass, package = "mlbench")
> index <- 1:nrow(Glass)
> testindex <- sample(index, trunc(length(index)/5))
> testset <- Glass[testindex, ]
> trainset <- Glass[-testindex, ]
> model <-
svm(datatrain,classestrain,type="C-classification",kernel="radial",cost=1,class.weights=Wts,probability=TRUE)
> pred_new.test <- predict(model,datatest,probability = TRUE)
> table.test <- table(pred_new.test,t(classestest))
> table.test
pred_new.test 1 2 3 5 6 7
1 12 3 1 0 0 0
2 1 15 0 0 0 0
3 0 0 0 0 0 0
5 0 0 0 1 0 0
6 0 0 0 0 1 0
7 0 1 0 1 0 6
> model <-
svm(datatrain,classestrain,type="C-classification",kernel="radial",cost=1,class.weights=Wts,probability=TRUE)
> pred_new.test <- predict(model,datatest,probability = TRUE)
> table.test <- table(pred_new.test,t(classestest))
> table.test
pred_new.test 1 2 3 5 6 7
1 12 3 1 0 0 0
2 1 14 0 0 0 0
3 0 0 0 0 0 0
5 0 0 0 1 0 0
6 0 1 0 0 1 0
7 0 1 0 1 0 6
> model <-
svm(datatrain,classestrain,type="C-classification",kernel="radial",cost=1,class.weights=Wts,probability=TRUE)
> pred_new.test <- predict(model,datatest,probability = TRUE)
> table.test <- table(pred_new.test,t(classestest))
> table.test
pred_new.test 1 2 3 5 6 7
1 12 3 1 0 0 0
2 1 13 0 0 0 0
3 0 0 0 0 0 0
5 0 0 0 1 0 0
6 0 1 0 0 1 0
7 0 2 0 1 0 6
Is this a feature or a bug?
More information about the R-help
mailing list