2
我建立了我的随机森林模型非常好,看到代码随机森林模型错误(错误的,如果(N == 0)停止(“数据(x)具有0行”))
modelRF <- randomForest(x=p$NDVI,
y=p$BushCategories,
ntree=500, do.trace=TRUE,
importance=TRUE, forest=TRUE, na.action=na.omit)
但随后,给出以下
Error in if (n == 0) stop("data (x) has 0 rows") :
argument is of length zero
错误请参见下面
'data.frame': 197 obs. of 5 variables:
$ Waypoint_No : chr "OMATSC028" "OMATSC200" "OMATSC072N" "OMATSC317" ...
$ Longitude : num 17.7 17.6 17.8 17.9 17.9 ...
$ Latitude : num -21.2 -21.2 -21.1 -20.9 -21.1 ...
$ NDVI : num 0.256 0.327 0.25 0.268 0.283 ...
$ BushCategories: Factor w/ 4 levels "0-25%","26-50%",..: 3 1 2 3 2 3 1 2 1
1 ...
我的数据的结构可能是什么问题呢?
这里是我的数据集看起来像
x<-c('0.256', '0.327', '0.25', '0.268')
y<-c('0-25%','26-50%','51-75%','76-100%')
data<-data.frame(x,y)
'na.action = na.omit'?你有没有每个行都有NAs的可能?请参阅http://stackoverflow.com/questions/8370455/how-to-build-random-forests-in-r-with-missing-na-values – zx8754
没有NAs,我已经删除了NA功能,仍然得到那个错误。 – jmutua
请提供[可重现的数据](http://stackoverflow.com/questions/5963269),所以我们得到相同的错误。 – zx8754