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

 

 

目录

输出结果

设计思路

核心代码


 

 

输出结果

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

1、eps=0.1,treeDepth=1

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

2、eps=0.1,treeDepth=5

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

2、eps=0.3,treeDepth=5

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

设计思路

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

 

核心代码

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))

 

 

 

更多文章请关注《万象专栏》