EL之GB(GBC):利用GB对多分类问题进行建模(分层抽样+调1参)并评估
EL之GB(GBC):利用GB对多分类问题进行建模(分层抽样+调1参)并评估
输出结果
T1、
T2、
设计思路
核心代码
#T1、
nEst = 500
depth = 3
learnRate = 0.003
maxFeatures = None
subSamp = 0.5
#T2、
# nEst = 500
# depth = 3
# learnRate = 0.003
# maxFeatures = 3
# subSamp = 0.5
glassGBMModel = ensemble.GradientBoostingClassifier(n_estimators=nEst, max_depth=depth,
learning_rate=learnRate, max_features=maxFeatures,
subsample=subSamp)
glassGBMModel.fit(xTrain, yTrain)
missClassError = []
missClassBest = 1.0
predictions = glassGBMModel.staged_decision_function(xTest)
for p in predictions:
missClass = 0
for i in range(len(p)):
listP = p[i].tolist()
if listP.index(max(listP)) != yTest[i]:
missClass += 1
missClass = float(missClass)/len(p)
missClassError.append(missClass)
if missClass < missClassBest:
missClassBest = missClass
pBest = p
赞 (0)