What is the difference between hard voting and soft voting in Random Forest classification?

Quick Overview

Asks how hard voting and soft voting combine the trees of a random forest classifier into one prediction. Tests whether you know where a tree's class probability comes from, when the two rules agree, and whether forest probabilities can be trusted as calibrated.

What is the difference between hard voting and soft voting in Random Forest classification?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

A random forest classifier has to combine the outputs of many decision trees into one prediction. What is the difference between hard voting and soft voting in Random Forest classification? ```hint What one tree outputs Besides its majority class, a leaf knows the class mix of the training samples that landed in it. Think about what that gives you when the leaf is not pure. ``` ```hint When the rules can disagree Compare the two rules for a forest whose leaves are all pure, then for a forest with impure leaves. ``` ### What a Strong Answer Covers - How each rule turns the trees' outputs into a single forest prediction - Where a single tree's class probability comes from - When the two rules give the same label and when they can differ - Which rule the original algorithm uses and which one scikit-learn's `RandomForestClassifier` uses - Whether the forest's averaged probabilities can be read as calibrated probabilities ### Follow-up Questions - Build a three-tree example where hard and soft voting predict different classes. - Why do random forest probabilities tend to stay away from 0 and 1, and how would you calibrate them? - Which hyperparameters make the two rules disagree more often, and why? - If you used hard voting, how would you still get a score for ranking or ROC AUC?

Overview: Asks how hard voting and soft voting combine the trees of a random forest classifier into one prediction. Tests whether you know where a tree's class probability comes from, when the two rules agree, and whether forest probabilities can be trusted as calibrated.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

A random forest classifier has to combine the outputs of many decision trees into one prediction. What is the difference between hard voting and soft voting in Random Forest classification?

What a Strong Answer Covers Guidance

  • How each rule turns the trees' outputs into a single forest prediction
  • Where a single tree's class probability comes from
  • When the two rules give the same label and when they can differ
  • Which rule the original algorithm uses and which one scikit-learn's RandomForestClassifier uses
  • Whether the forest's averaged probabilities can be read as calibrated probabilities

Follow-up Questions Guidance

  • Build a three-tree example where hard and soft voting predict different classes.
  • Why do random forest probabilities tend to stay away from 0 and 1, and how would you calibrate them?
  • Which hyperparameters make the two rules disagree more often, and why?
  • If you used hard voting, how would you still get a score for ranking or ROC AUC?