Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 541
user3251223 Avatar asked Oct 20 '25 04:10

user3251223


1 Answers

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)
like image 172
user3251223 Avatar answered Oct 22 '25 18:10

user3251223