How to calculate mode of votes in an ensemble in R

ensemble_methods
mode
r

#1

I am currently trying to solve one classification problem for improving my model performance I have created three xgboost model .Then I have created a data frame which include the id and output of all three model.I am trying to find the maximum frequency of output from the three output for this I have used apply function on to it.But I am getting the error.

Mode <- function(x) {
u <- unique(x)
u[which.max(tabulate(match(x, u)))]
}

y <- apply(submit_match3[,-1],1,Mode) # removing the id column
data.table(y)


#2

hello @harry,

Assuming you are not attaching weights to the classifiers,here is what you can do:

In case you have 3 classifiers you can simply:

  1. add the votes up
    2.If the sum is >= 2 then it is classified as 1 else as 0.

In the above example,record 1 is classified as 1,record 2 as 0,record 3 as 1 and so on.

Hope this helps!!