user3251223
user3251223

Reputation: 265

How do you change the cutoff parameter in R's randomForest?

The documentation says cutoff is "A vector of length equal to number of classes. The `winning' class for an observation is the one with the maximum ratio of proportion of votes to cutoff. Default is 1/k where k is the number of classes (i.e., majority vote wins)."

I want to implement a cutoff of probabilities of 0.6 or 0.7 not the default of 0.5.

RFfit <- randomForest(Y ~ x1 + x2 + x3 + x4 + x5, data=mydata, mytry=2, ntrees=500,
  cutoff = x)

I have tried various values for x. 0.6, 6, 12, 1.2... none seem to work. I have also added a column called "cutoff" to my data where all values are = 0.6, and tried calling that into the code, but that did not work either.

How do I use the cutoff argument properly?

Upvotes: 4

Views: 14095

Answers (1)

user3251223
user3251223

Reputation: 265

The correct format is

cutoff=c(k,1-k) 

Where k can be any value between 0 and 1. For example,

cutoff=(0.7,1-0.7)

or

cutoff=(0.5,1-0.5)

Upvotes: 7

Related Questions