library(xlsx)
##读取数据
data<-read.xlsx(file="D:/R workplace/Random Forest Regression/RandomForest dataset.xlsx",sheetIndex=1)
##去掉日期那一列
data2<-data[,-1]
##做随机森林
sales.rf<-randomForest(y~.,data=data2,importance=TRUE)
##进行预测
predict(sales.rf,data2[1,2:5])
data2[1,1]##真值
##查看参数重要性,数字越大,则其越重要
importance(sales.rf)


雷达卡





京公网安备 11010802022788号







