EL之GB(GBC):利用GB对二分类问题进行建模并评估

EL之GB(GBC):利用GB对二分类问题进行建模并评估


输出结果

T1、纯GB算法

T2、以RF为基学习器的GB算法

设计思路

核心代码

# nEst = 2000
# depth = 3
# learnRate = 0.007
# maxFeatures = None

nEst = 2000
depth = 3
learnRate = 0.007
maxFeatures = 20

rockVMinesGBMModel = ensemble.GradientBoostingClassifier(n_estimators=nEst, max_depth=depth,
                                                         learning_rate=learnRate,
                                                         max_features=maxFeatures)

rockVMinesGBMModel.fit(xTrain, yTrain)

auc = []
aucBest = 0.0
predictions = rockVMinesGBMModel.staged_decision_function(xTest)
for p in predictions:
    aucCalc = roc_auc_score(yTest, p)
    auc.append(aucCalc)

    if aucCalc > aucBest:
        aucBest = aucCalc
        pBest = p
(0)

相关推荐