1
我試圖使用randomForest
包中的rfcv
函數。我收到的錯誤消息如下:R rfcv無法拆分數據
> rfcv1 <- rfcv(x[1:18750,], testClass[1:18750], cv.fold=2)
Error in cut.default(trainy, c(-Inf, quantile(trainy, 1:4/5), Inf)) :
'breaks' are not unique
> nrow(unique(x[1:18750,]))
[1] 18719
> length(unique(testClass[1:18750])) ## just 0's and 1's
[1] 2
> head(x)
rfPred prediction
3 0.34776664 0.30138045
5 0.22345507 0.11159273
7 0.03478699 0.02156816
17 0.01008994 0.01071626
24 0.01738253 0.01546157
25 0.01143016 0.01278491
> range(x)
[1] 0.003907361 0.966005867
什麼都顯得不對?我試圖收縮數據,以便唯一值可以被5整除,但仍然會得到相同的信息。我也嘗試了各種cv.fold=
值沒有效果。
就是這樣,只是圍繞它投擲as.factor(),它工作。非常感謝你。 – screechOwl