分享

EL之Boosting之GB(DTR):简单回归问题使用梯度提升法(DIY数据集+DTR模型+调两参)

 处女座的程序猿 2021-09-28

EL之Boosting之GB(DTR):简单回归问题使用梯度提升法(DIY数据集+DTR模型+调两参)


输出结果

1、eps=0.1,treeDepth=1

2、eps=0.1,treeDepth=5

2、eps=0.3,treeDepth=5

设计思路

核心代码

for iTrees in range(numTreesMax):

    modelList.append(DecisionTreeRegressor(max_depth=treeDepth))
    modelList[-1].fit(xTrain, residuals)
    
    latestInSamplePrediction = modelList[-1].predict(xTrain)

    residuals = [residuals[i] - eps * latestInSamplePrediction[i] for i in range(len(residuals))]

    latestOutSamplePrediction = modelList[-1].predict(xTest)
    predList.append(list(latestOutSamplePrediction))


mse = []
allPredictions = []
for iModels in range(len(modelList)):

    prediction = []
    for iPred in range(len(xTest)):
        prediction.append(sum([predList[i][iPred] for i in range(iModels + 1)]) * eps)

    allPredictions.append(prediction)
    errors = [(yTest[i] - prediction[i]) for i in range(len(yTest))]
    mse.append(sum([e * e for e in errors]) / len(yTest))

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多