Ivo
Ivo

Reputation: 1

Hard Voting Classifier: What happens in case of a tie (sklearn)

I have 9 different models for a classification problem with three possible outputs. I want to do VotingClassifier with a hard voting mechanism.

Sounds easy, just count how often which class is predicted. But if I want to use the function instead of programming it myself, what happens by a tie?

For example:

I tried to find some pattern but no chance. It is not ascending or something else, it looks random. Is there a possibility, that when a tie happens, I can say "use class 4"?

I trid already to figure out some pattern, without success..

Upvotes: 0

Views: 47

Answers (1)

Ben Reiniger
Ben Reiniger

Reputation: 12582

The "first" class (using python's sort order, so alphabetically for string classes) among the ties is the final prediction. From the User Guide:

In the cases of a tie, the VotingClassifier will select the class based on the ascending sort order. E.g., in the following scenario

  • classifier 1 -> class 2

  • classifier 2 -> class 1

the class label 1 will be assigned to the sample.

Upvotes: 0

Related Questions