安迪和大林的舅妈 2022-03-22 08:27 采纳率: 0%
浏览 104

R语言引用caret包做训练模型报错

想做一个knn预测数据,然后引用caret包做数据集切割后用想用train函数拟合训练模型,但是报错说缺少randomForest包,然后但我自己想装一个随机森林的时候发现R版本不适用😖已经崩溃了,下附代码。麻烦大家帮康康,谢谢啦。

library(caret)
train_id <- createDataPartition(y=GaltonFamilies$childHeight,p=0.75,list=FALSE)
train_data <- GaltonFamilies[train_id, ]
test_data <- GaltonFamilies[-train_id, ]
nrow(train_data)
nrow(test_data)

prop.table(table(train_data$childHeight))
prop.table(table(test_data$childHeight))

control<-trainControl(method = "cv",number = 10)
model<-train(childHeight~.,data=train_data,methed="knn",preProcess=c("center","scale"),trControl = control,tuneLength = 5)
model

报错

1 package is needed and is not installed. (randomForest). Would you like to try to install it now?
1: yes
2: no

Selection: 1
Installing package into ‘C:/Users/ss/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
错误: package randomForest is required
此外: Warning message:
package ‘randomForest’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

  • 写回答

1条回答 默认 最新

  • 「已注销」 2022-03-22 13:24
    关注

    缺少某些库了

    评论

报告相同问题?

问题事件

  • 创建了问题 3月22日

悬赏问题

  • ¥15 iE 浏览器不能访问 oracle secure global server, google 浏览器可以
  • ¥50 Namuru2007_Baseband_Verilog代码疑点
  • ¥15 复杂公式求最值问题,含有多个符号常量
  • ¥15 Qt移植后在开发板上无法运行
  • ¥15 关于STID337-32D15YB开发板LINUX调试
  • ¥15 有没有熟悉自动化点胶设备,有个加密狗,想复制一份软件到另个设备
  • ¥15 mysql 部分截取字符串
  • ¥20 只有一个C盘,磁盘管理分区
  • ¥15 PVE8.2版本ceph的监控项状态stopped不能销毁
  • ¥15 如何加快视频观看速度?