数据分区函数CreateDataPartition交叉验证问题

如何解决数据分区函数CreateDataPartition交叉验证问题

我试图预测一个多变量模型,它的 eplt,它由 7 个分数和一个期末考试分数 moy_exam2 组成,我想使用 7 个分数预测后者,我有 29441 个 obs,像这样:

'data.frame':   19643 obs. of  8 variables:
 $ HG       : num  11.5 14 7.5 10.5 9.5 9.5 10 14 11.5 14 ...
 $ Math     : num  8 7.25 9.25 13.25 4.25 ...
 $ Ar       : num  11.2 12.8 8.5 11.5 9.5 ...
 $ Fr       : num  4 4.25 6.5 6.75 5.5 ...
 $ EI       : num  8 10.5 2.5 4 7 9.5 8.5 9.5 12 14 ...
 $ SVT      : num  5.25 9.25 7 11.5 12.5 ...
 $ PC       : num  11.5 16.75 4.25 13.75 10 ...
 $ moy_exam2: num  8.15 9.48 7.23 10.33 7.44 ...

我决定 85% 用于训练,15% 用于测试模型,因此在使用 CreateDataPartition 对数据进行分区时,我尝试这样做:

# Load the data
data("neplt")
# Inspect the data
library(tidyverse)
sample_n(neplt,3)
# Split the data into training and test set
set.seed(1,sample.kind = "Rounding")
#remember the last sample 
training.samples=neplt$moy_exam2
library(Rcpp)
training.samples <- neplt$moy_exam2 %>%
createDataPartition(neplt,p = 0.85,list = FALSE,times = 1)
train.data  <- neplt[training.samples,]
test.data <- neplt[-training.samples,]
# Build the model
model <- lm(moy_exam2 ~.,data = train.data,na.action=na.omit)
# Make predictions and compute the R2,RMSE and MAE
predictions <- model %>% predict(test.data)
data.frame( R2 = R2(predictions,test.data$moy_exam2),RMSE = RMSE(predictions,MAE = MAE(predictions,test.data$moy_exam2))

我知道错误

Error in split_indices(as.integer(splitv),attr(splitv,"n")) : 
function 'Rcpp_precIoUs_remove' not provided by package 'Rcpp'

在这里不使用任何 split_indices 函数!!并且 Rccp 已经加载,所以我继续执行,但程序卡在 CreateDataPartition 行上, 我使用 epltna.omit 清理数据 na.exclude 以消除对 NA 缺失值的任何疑问, 然后,我尝试将 sample.kind = "Rounding" 属性添加set.seed 以使其工作,但 Rstudio 仍然无限期地加载,并且控制台显示 + 号

enter image description here

enter image description here

好像和内存容量有关?或者它有无限数量的样本,它在100年内无法完成!!,它已经运行了几个小时没有结果!

请帮忙,谢谢!!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?