【发布时间】:2020-11-12 15:43:30
【问题描述】:
我有一个线性回归随机森林模型,可以根据一组变量预测植物高度。
training <- read.csv('/sers/me/Desktop/training_data.csv')
rf_model <- randomForest(height ~ EVI + NDVI + Annual_Mean_Temperature + Annual_Precipitation + Precipitation_of_Wettest_Month, data = training, importance=TRUE, na.action = na.roughfix)
但是,当我查看预测值时,我看到了一些负数,尽管我的训练数据集中没有因变量的负值——因为我正在预测植物高度,所以负值在物理上是不可能的。
> min(rf_model$predicted)
-4.433786671143025159836e-12
我检查了我的训练集,这里没有负值,所以这是怎么回事/我该怎么办?
> min(training$height)
0
【问题讨论】:
-
看起来像是机器容差问题。
-0.0000000000044非常接近0。我不会担心它,只是圆形。 -
我同意。 RandomForest 是用 Fortran 编写的,因此很可能只是由 Fortan 中的机器容差或包如何将 Fortran 中的数字转换为 R 或相反
标签: r linear-regression random-forest