輸出結果
設計思路
核心代碼
#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))