GradientBoostingRegressor http://scikit-learn.org/为上限和下限提供相同的预测间隔

时间:2015-11-06 18:03:01

标签: python

我尝试获取GradientBoostingRegresso的预测间隔 每 http://scikit-learn.org/stable/auto_examples/ensemble/plot_gradient_boosting_quantile.html#example-ensemble-plot-gradient-boosting-quantile-py

#  GradientBoostingRegrKessor
# up
alpha_GBR_up = 0.95        
#model_GBR_up = GradientBoostingRegressor(loss='quantile', alpha=alpha, n_estimators = n_trees_simple_RF, learning_rate=0.1,  max_depth=1, random_state= rnd_seed)
model_GBR_up = GradientBoostingRegressor(loss='quantile', alpha=alpha_GBR_up, n_estimators = n_trees_simple_RF, learning_rate=0.1,   random_state= rnd_seed)        
model_GBR_up.fit(past_matrix_RF[:-n_games_test],  true_pts_for_RF[:-n_games_test])      
predicted_pts_simple_GBR_upper  = model_GBR_up.predict(past_matrix_RF)
#down
alpha_GBR_lower =1.0 - alpha_GBR_up
#model_GBR_lower = GradientBoostingRegressor(loss='quantile', alpha=alpha, n_estimators = n_trees_simple_RF, learning_rate=0.1,  max_depth=1, random_state= rnd_seed)
model_GBR_lower = GradientBoostingRegressor(loss='quantile', alpha=alpha_GBR_lower, n_estimators = n_trees_simple_RF, learning_rate=0.1,  random_state= rnd_seed)
model_GBR_lower.fit(past_matrix_RF[:-n_games_test],  true_pts_for_RF[:-n_games_test])
predicted_pts_simple_GBR_lower  = model_GBR_up.predict(past_matrix_RF)

# middle
#model_GBR = GradientBoostingRegressor(loss='ls', n_estimators = n_trees_simple_RF, learning_rate=0.1,  max_depth=1, random_state= rnd_seed)
model_GBR = GradientBoostingRegressor(loss='ls', n_estimators = n_trees_simple_RF, learning_rate=0.1,  random_state= rnd_seed)
model_GBR.fit(past_matrix_RF[:-n_games_test],  true_pts_for_RF[:-n_games_test])
predicted_pts_simple_GBR  = model_GBR.predict(past_matrix_RF)

#    plot
fig = plt.figure(15110606)
plt.plot(predicted_pts_simple_GBR_upper,'go',label = ' predicted_pts_simple_GBR_upper')
plt.plot(predicted_pts_simple_GBR_lower,'cp',label = ' predicted_pts_simple_GBR_lower'   ) 
plt.plot(predicted_pts_simple_GBR,'rd',label = ' predicted_pts_simple_GBR' )        
plt.title("  player  " +  df_player['Name'][1] + '  team ' + df_player['Team'][1] )
plt.xlabel ("Game Number  (not actual , but only order) number of games for test = " + str(n_games_test))
plt.ylabel("PTS") 
plt.plot(predicted_pts_simple_GBR_upper,'g')

plt.plot(predicted_pts_simple_GBR,'r')

plt.plot(predicted_pts_simple_GBR_lower,'--c')
fig.show()
pp.savefig()  

但我得到了相同的预测间隔,用于上限和下限 您可能会告诉我在示例中更改了一些参数,但即使更改了示例也可以

clf = GradientBoostingRegressor(loss='quantile', alpha=alpha,n_estimators=250, learning_rate=.1) 

并且似乎是获得整体学习的间隔的唯一方法,因为随机森林没有它

0 个答案:

没有答案