%autosave 10 from sklearn.ensemble import GradientBoostingClassifier from sklearn.datasets import make_hastie_10_2 X, y = make_hastie_10_2(n_samples=10000) est = GradientBoostingClassifier(n_estimators=200, max_depth=3) est.fit(X, y) pred = est.predict(X) est.predict_proba(X)[0] # class probabilities for pred in est.staged_predict(X): plt.plot(X[:, 0], pred, color='r', alpha=0.1) # X_test/Y_test, held back data test_score = np.empty(len(est.estimators_)) for i, pred in enumerate(est.staged_predict(X_test)): test_score[i] = est.loss_(y_test, pred) plt.plot(np.arange(n_estimators) + 1, test_score, label='Test') plt.plot(np.arange(n_estimators) + 1, est.train_score_, label='Train')