为什么我使用randomForest得到负%var

为什么我使用randomForest得到负%var,r,R,我试图使用randomForest为我在R中的数据集拟合回归模型。我的数据集有17个分类自变量和8个数值自变量。因变量是数值型的。这是我的r脚本: #view data structure str(my.data2) #Partition data to train and test ind<-sample(2,nrow(my.data2),replace = TRUE, prob=c(0.8,0.2)) train <- my.data2[ind==1,] test <-

我试图使用randomForest为我在R中的数据集拟合回归模型。我的数据集有17个分类自变量和8个数值自变量。因变量是数值型的。这是我的r脚本:

#view data structure
str(my.data2)


#Partition data to train and test
ind<-sample(2,nrow(my.data2),replace = TRUE, prob=c(0.8,0.2))
train <- my.data2[ind==1,]
test <- my.data2[ind==2,]

#Fitting the Random Forest Regression Model to the dataset
install.packages("randomForest")
library(randomForest)
set.seed(123)
regressor = randomForest(x = my.data2[1],
                     y = my.data2$`GPS Utilization Rate`,
                     ntree = 100)

您只对一个变量与另一个变量进行回归。您应该在模型中包含所有预测值当请求帮助时,您应该包含一个简单的示例输入和所需输出,可用于测试和验证可能的解决方案。为my.data2提供数据,这样我们就可以运行代码来查看发生了什么。
Call:
 randomForest(x = my.data2[1], y = my.data2$`GPS Utilization Rate`,         ntree = 100) 
           Type of random forest: regression
                 Number of trees: 100
No. of variables tried at each split: 1

      Mean of squared residuals: 0.03384334
                % Var explained: -0.09