尝试使用插入符号库和方法“svm-radial”通过以下代码获取因变量的类概率。我在虹膜数据集上尝试过它。
# finding optimal value of a tuning parameter
sigDist <- sigest(Species ~ . , data=Train, frac=1)
# creating a grid of two tuningparameters, .sigma comes from the earlier line.
# we are trying to find best value of C
svmTuneGrid <- data.frame(.sigma=sigDist[1], .C=2^(-2:7))
model_svmRadial <- train(Species ~. , data=Train, method='svmRadial', preProc=c("center","scale"),tuneGrid=svmTuneGrid , trControl=myControl,classProbs=TRUE)
产生错误和警告:
model_svmRadial <- train(Species ~. , data=Train, method='svmRadial', preProc=c("center","scale"),tuneGrid=svmTuneGrid , trControl=myControl,classProbs=TRUE)
Something is wrong; all the Accuracy metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :10 NA's :10
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: There were 31 warnings (use warnings() to see them)
删除classProbs = TRUE,列车功能正常。但我需要班级概率。 请建议如何摆脱错误。 感谢您的期待。
答案 0 :(得分:1)
您应该将classProbs
放在trainControl
内而不是train
内,例如:
myControl <- trainControl(method= "cv",
number = 10,
classProbs = TRUE)