Hi,

It appears there is an OSX-specific bug in the function
`randomForest.default()` Going by the source code at
https://github.com/cran/randomForest/blob/master/R/randomForest.default.R
the bug is on line 103

If the vector `cutoff` is formed using `cutoff <- rep(1/9, 9)` (line #101)
the test on line 103 will fail on OSX as the sum is greater than 1 due to
machine precision errors.

sum(rep(1 / 9, 9)) - 1
# [1] 2.220446e-16

This will actually occur for a scenario when the number of factor levels
(nclass) is 9, 11, 18, 20 etc.The problem does not occur on Linux, and I
haven't tested on WIndows.

A suggestion may be to change the opening test

if (sum(cutoff) > 1 || ...)

to

if (sum(cutoff) - 1  > .Machine$double.eps || ...

however, I'm sure there's a more elegant way to do this

Thanks in advance

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to