What is the difference between class_weight='balanced' and class_weight='balanced_subsample' in a Random Forest?

Last updated 5 November 2026

  • Both reweight classes inversely to frequency (n_samples / (n_classes * np.bincount(y))). 'balanced' computes weights once from the full training labels.

  • 'balanced_subsample' recomputes weights from each tree's bootstrap, so every tree is exactly balanced. It only differs when bootstrap=True and matters most with a tiny minority class.

  • Neither resamples data, unlike a Balanced Random Forest which undersamples.

  • https://www.geeksforgeeks.org/machine-learning/how-does-the-classweight-parameter-in-scikit-learn-work/
  • https://medium.com/grabngoinfo/balanced-weights-for-imbalanced-classification-465f0e13c5ad
  • https://github.com/NVIDIA/cuml/issues/8146
All Random Forests interview questions