svm的非确定性行为{e1071}

时间:2014-06-04 13:54:07

标签: r machine-learning svm

我注意到当使用decision.values = T(加上sigmoid来获取概率)时,SVM会在我分析下置换数据帧时产生非确定性结果。有谁知道为什么?请亲自尝试代码

install.packages("e1071")
library(e1071)
A <- cbind(rnorm(20,1,1),rnorm(20,1,1),rep(1,20))
B <- cbind(rnorm(20,9,1),rnorm(20,9,1),rep(0,20))

dataframe <- as.data.frame(rbind(A,B))

predc <- rep(0,length(dataframe[,1]))
K <- length(dataframe[1,])
permutator <- sample(nrow(dataframe))

dataframe$V3 <- factor(dataframe$V3)
dataframe <- dataframe[permutator, ]
for(i in 1:length(dataframe[,1])) {    

  frm <- as.formula(object=paste("V",as.character(K), " ~ .",sep=""))
  r <- svm(formula=frm, data=(dataframe[-i,]))
  predicted <- predict(r,newdata=dataframe[i,],decision.values=TRUE)
  predc[i] <- sigmoid(attr(predicted,'decision.values')[1])
}


plot(sort(predc))

[编辑:代码]

0 个答案:

没有答案