In this example, we want to employ a gradient tree boosting classifier (class GradientBoostingClassifier) and check the impact of the maximum tree depth (parameter max_depth) on the performance. Considering the previous example, we start by setting n_estimators=50 and learning_rate=0.8:
import numpy as npfrom sklearn.ensemble import GradientBoostingClassifierfrom sklearn.model_selection import cross_val_scorescores_md = []eta = 0.8for md in range(2, 13): gbc = GradientBoostingClassifier(n_estimators=50, learning_rate=eta, max_depth=md, random_state=1000) scores_md.append(np.mean(cross_val_score(gbc, X, Y, cv=10)))
The result is shown in the following diagram: