如何解决数据分区函数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 行上,
我使用 eplt
和 na.omit
清理数据 na.exclude
以消除对 NA 缺失值的任何疑问,
然后,我尝试将 sample.kind = "Rounding"
属性添加到 set.seed
以使其工作,但 Rstudio 仍然无限期地加载,并且控制台显示 + 号
好像和内存容量有关?或者它有无限数量的样本,它在100年内无法完成!!,它已经运行了几个小时没有结果!
请帮忙,谢谢!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。