What is the difference between class_weight='balanced' and class_weight='balanced_subsample' in a Random Forest?
Last updated
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 whenbootstrap=Trueand matters most with a tiny minority class.Neither resamples data, unlike a Balanced Random Forest which undersamples.