#coding=utf-8
#coding:utf-8
#-*- coding:utf-8 -*-
 
import numpy as np
from sklearn.ensemble import GradientBoostingClassifier,GradientBoostingRegressor
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_wine,load_boston
wine = load_wine()
Xtrain, Xtest, Ytrain, Ytest = train_test_split(wine.data,wine.target,test_size=0.3)
print(Ytrain)
 
#默认参数
#Accuracy : 0.9856
#AUC Score (Train): 0.862264
gbm1 = GradientBoostingClassifier( n_estimators=500,max_depth=10,max_features='sqrt', random_state=10)
gbm1.fit(Xtrain,Ytrain)
print("gbdt1",gbm1.score(Xtest,Ytest))

boston = load_boston()
Xtrain, Xtest, Ytrain, Ytest = train_test_split(boston.data, boston.target, test_size=0.3)
print(Ytrain)

# 默认参数
# Accuracy : 0.9856
# AUC Score (Train): 0.862264
gbm2 = GradientBoostingRegressor(n_estimators=5, max_depth=5, max_features='sqrt', random_state=10)
gbm2.fit(Xtrain, Ytrain) # 分数越高越好
print("gbdt1", gbm2.score(Xtest, Ytest))

gbm2 = GradientBoostingRegressor(n_estimators=50, max_depth=5, max_features='sqrt', random_state=10)
gbm2.fit(Xtrain, Ytrain)
print("gbdt2", gbm2.score(Xtest, Ytest))

gbdt3 = GradientBoostingRegressor(n_estimators=150, max_depth=5, max_features='sqrt', random_state=10)
gbdt3.fit(Xtrain, Ytrain)
print("gbdt3", gbdt3.score(Xtest, Ytest))
