如何在R中的机器学习算法重复中设置种子?
How to set the seed in repetiton of machine learning algorithm in R?
我的目标是 运行 机器学习算法 100 次,但为了泛化目的,我必须设置种子。我的问题是在迭代循环中设置种子的最佳方式是什么?目前,我想到的唯一方法是:
for (i in 1:100){
set.seed(i)
The rest of the code in here
}
如有任何意见,我们将不胜感激。
两种解决方案都有效,但 "outside the loop" 解决方案只能作为一个整体重现,而如果您设置它 "inside the loop",则每次迭代都可以单独重现。
我的目标是 运行 机器学习算法 100 次,但为了泛化目的,我必须设置种子。我的问题是在迭代循环中设置种子的最佳方式是什么?目前,我想到的唯一方法是:
for (i in 1:100){
set.seed(i)
The rest of the code in here
}
如有任何意见,我们将不胜感激。
两种解决方案都有效,但 "outside the loop" 解决方案只能作为一个整体重现,而如果您设置它 "inside the loop",则每次迭代都可以单独重现。