当我尝试从Knn fold - cv
获取准确的输出时,会得到零列表。
我不知道如何解决它,而实际上无法在数据框中获得准确的结果。
示例
anchoring <- read.delim("anchoring.csv", header = TRUE, sep=",",
stringsAsFactors = FALSE)
ggg <- data.frame(anchoring$Guess, anchoring$Label, anchoring$Cond)
aaa<- subset(ggg, ggg$anchoring.Cond!="Neutral")
aaa$anchoring.Cond = factor(aaa$anchoring.Cond)
arrange(aaa, aaa$anchoring.Guess)
yyy<-function(iii){
set.seed(1)
income_knn = train(anchoring.Cond ~ ., method = "knn", data = iii,
trControl = trainControl(method = 'cv', number = 10,
returnResamp = "all"))
return(jjj$results$Accuracy)
}
jjj<-(lapply(split(aaa, aaa$anchoring.Label), yyy))
nnn<-as.data.frame(as.matrix(jjj))