Atelier : forêt contre boosting
Duel tabulaire avec budget temps et interprétation.
Énoncé
Sur tabulaire mixte : RandomForest vs HistGradientBoosting en pipelines (one-hot dedans), CV 3 folds, verdict test avec métrique adaptée + importance par permutation du gagnant + temps.
Contraintes
Encodage dans le pipeline, arrêt précoce pour boosting, test unique, fiche avec limites.
Indices
RandomForestClassifier(n_estimators=300, random_state=0), HistGradientBoostingClassifier(early_stopping=True).
Correction disponibleCherchez d’abord par vous-même.Voir la correction
Correction
from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
rf = make_pipeline(prep, RandomForestClassifier(n_estimators=300, random_state=0))
gb = make_pipeline(prep, HistGradientBoostingClassifier(early_stopping=True, random_state=0))
Attendu type : boosting ≥ forêt de 0-2 points mais 2-5x plus sensible aux graines/bruit. Si écart < marge, livrez la forêt : plus simple à défendre en revue ingénieur.