天天看點

EL之GB(GBM):利用GB對回歸(性别屬性編碼+調2參)問題(整數值年齡預測)模組化

輸出結果

EL之GB(GBM):利用GB對回歸(性别屬性編碼+調2參)問題(整數值年齡預測)模組化
EL之GB(GBM):利用GB對回歸(性别屬性編碼+調2參)問題(整數值年齡預測)模組化

設計思路

EL之GB(GBM):利用GB對回歸(性别屬性編碼+調2參)問題(整數值年齡預測)模組化
EL之GB(GBM):利用GB對回歸(性别屬性編碼+調2參)問題(整數值年齡預測)模組化

核心代碼

#T1

nEst = 2000

depth = 5

learnRate = 0.003

maxFeatures = None

subsamp = 0.5

#T2

# nEst = 2000

# depth = 5

# learnRate = 0.005

# maxFeatures = 3

# subsamp = 0.5

abaloneGBMModel = ensemble.GradientBoostingRegressor(n_estimators=nEst, max_depth=depth,

                                                    learning_rate=learnRate, max_features=maxFeatures,

                                                    subsample=subsamp, loss='ls')

abaloneGBMModel.fit(xTrain, yTrain)

# compute mse on test set

msError = []

predictions = abaloneGBMModel._staged_decision_function(xTest)

for p in predictions:

   msError.append(mean_squared_error(yTest, p))

繼續閱讀