<jupyter_start><jupyter_text>Validation Curve<jupyter_code>train_scores, valid_scores = validation_curve(GradientBoostingRegressor(), X_train, y_train.loc[:,"Gen Change (MW)"], "n_estimators", [100, 200, 400])

train_scores_mean = np.mean(train_scores, axis=1)
train_scores_std = np.std(train_scores, axis=1)
valid_scores_mean = np.mean(valid_scores, axis=1)
valid_scores_std = np.std(valid_scores, axis=1)

plt.title("Validation Curve - SVR")
plt.xlabel("C")
plt.ylabel("Score")
plt.ylim(0.0, 1)
lw = 2
param_range = range(0, 3)
plt.semilogx(param_range, train_scores_mean, label="Training score",
             color="darkorange", lw=lw)
plt.fill_between(param_range, train_scores_mean - train_scores_std,
                 train_scores_mean + train_scores_std, alpha=0.2,
                 color="darkorange", lw=lw)
plt.semilogx(param_range, valid_scores_mean, label="Cross-validation score",
             color="navy", lw=lw)
plt.fill_between(param_range, valid_scores_mean - valid_scores_std,
                 valid_scores_mean + valid_scores_std, alpha=0.2,
                 color="navy", lw=lw)
plt.legend(loc="best")
plt.show()
gb_gs.best_params_
gb_gs.best_index_
gbr2 = GradientBoostingRegressor(max_depth= 5, n_estimators= 100)
gbr2.fit(X_train, y_train.loc[:,'Gen Change (MW)'])
gbr2.score(X_cv, y_cv.loc[:,'Gen Change (MW)'])
X_cv.tail()
y_pr = gbr2.predict(X_cv)
y_resids = y_cv
y_resids.loc[:,'y_pr'] = y_pr
y_resids.head()
y_resids.loc[:,'residuals'] = y_resids.loc[:, 'y_pr'] - y_resids.loc[:,'Gen Change (MW)']
g = sns.FacetGrid(y_resids, hue='cluster_id_6', col='cluster_id_6',
                  col_wrap=3)
g.map(plt.scatter, 'Gen Change (MW)', 'residuals')
g.add_legend()
plt.scatter(y_pr-y_cv.loc[:,'Gen Change (MW)'], y_cv.loc[:,'Gen Change (MW)'])
plt.ylabel('y_pr - y_va')
plt.xlabel('y_va')
gbr2.predict(X_cv.tail())
y_cv.head()
y_cv.tail()
zip(X_train.columns, gbr2.feature_importances_)
gbr2.feature_importances_
zip(X_train.columns, gbr.feature_importances_)
zip(X_train.columns, gb_gs.feature_importances_)
gbr.get_params<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1563251563251563, 'fraction_numerical': 0.017797017797017797, 'mean_word_length': 5.52037617554859, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '19714', 'license': 'MIT', 'n_tokens_mistral': 905, 'n_tokens_neox': 838, 'n_words': 126, 'path': 'Prediction model/sklearn gradientboosting.ipynb', 'repo_name': 'nikhilba/ERCOT', 'size': '2079'}