c – RcppShark随机森林示例抛出有关随机数生成器的异常

我按照这个例子:

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

The random number generator was replaced, as R packages must use the random generator from R and not the C/C++ internal one. Thereffore, a direct comparison of results of algorithms that depend on (pseudo) random numbers cannot be done.

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

尝试了两个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

转载注明原文:c – RcppShark随机森林示例抛出有关随机数生成器的异常 - 代码日志