【问题标题】:R caret with reproducible outcome/results具有可重复结果/结果的 R 插入符号
【发布时间】:2017-12-26 21:34:21
【问题描述】:

我正在使用R 中的caret 包进行一些有监督的多变量分析。我正在尝试向我的脚本添加一些功能,以便在脚本运行时产生可重现的结果。

我有这个设置用于使用 2 个分类模型(每个模型单独运行,而不是作为一个整体运行):

library(caret)

load.data = ....
cleaned.data = cleaning(load.data)
mycontrol = trainControl(...)
train, test = createDatapartition(...)

model1 = train(...,
               data=train, ...,
               trControl=mycontrol,
               preprocess=c('center'))
model2 = train(...,
               data=train, ...,
               trControl=mycontrol,
               preprocess=c('pca'))

feature.importances = ...
summary(resamples(list(m1=model1,m2=model2)))
learing_curve_dat(...) #see link 1. below.
predict()
Evaluate(....) #see link 2. below

我应该在这个管道中的哪个位置使用 set.seed(#) 以及 # 应该是什么以便在每次运行脚本时获得可重现的结果 - 还是我只是随机选择 # 的任何值?

链接:

1. 2.

【问题讨论】:

    标签: r r-caret random-seed


    【解决方案1】:

    您应该阅读包装网页上的Notes on Reproducibility 部分。

    种子数无关紧要。我用sample.int(100000, 1) 生成一个。根据你如何做模型,你至少应该在调用 train 之前设置种子(但请阅读上面的链接)。

    【讨论】:

      猜你喜欢
      • 2016-11-22
      • 2023-03-28
      • 2018-10-31
      • 2016-01-30
      • 1970-01-01
      • 2020-04-26
      • 2020-08-17
      • 2017-07-22
      • 2014-11-21
      相关资源
      最近更新 更多