RcppShark 随机森林示例引发有关随机数生成器的异常

RcppShark Random Forest example throws exception about the random number generator

本文关键字:随机数生成器 异常 随机 森林 RcppShark      更新时间:2023-10-16

我遵循了这个例子:

https://www.2021.ai/randsharkmachinelearning/

在 R 上运行此命令时:

sharkFit <- SharkRFTrain(X, Y, nTrees = 100)

我得到:

Error in SharkRFTrain(X, Y, nTrees = 100) : 
Should not call this. Fix the random numbers generator if you need this. 478

此异常从此"cpp"行引发:

trainer.train(model, trainData);

我怀疑原因写在这里:

https://github.com/aydindemircioglu/RcppShark#notes

随机数生成器已被替换,因为 R 包必须使用 R 中的随机生成器,而不是 C/C++ 内部生成器。因此,无法对依赖于(伪(随机数的算法结果进行直接比较。

有没有办法缓解这种情况?

尝试了两个 R 版本: 3.4.1, 3.3.2

我已经对此进行了调查,并能够在一定程度上缩小范围:

错误消息
  • 如下所示:https://github.com/aydindemircioglu/RcppShark/blob/master/src/shark/Rng/Runif.h#L71
  • 调用代码在这里:https://github.com/aydindemircioglu/RcppShark/blob/master/src/src/Algorithms/RFTrainer.cpp#L178

由于我无法修复它,我在这里打开了一个问题:https://github.com/aydindemircioglu/RcppShark/issues/1