EL之RF:利用RandomForestRegressor对回归问题(实数值评分预测)建模(调2参)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41185868/article/details/86096013

EL之RF:利用RandomForestRegressor对回归问题(实数值评分预测)建模(调2参)

输出结果

设计思路

核心代码

mseOos = []
nTreeList = range(100, 1000, 100)    #----▲☆▲☆▲
for iTrees in nTreeList:
#     depth = None
#     depth=6      #----▲▲▲▲▲
    depth=10     #----☆☆☆☆
    
    maxFeat  = 4 #try tweaking

    wineRFModel = ensemble.RandomForestRegressor(n_estimators=iTrees, max_depth=depth, max_features=maxFeat,
                                                 oob_score=False, random_state=531)
    
    wineRFModel.fit(xTrain,yTrain)
    prediction = wineRFModel.predict(xTest)
    mseOos.append(mean_squared_error(yTest, prediction))

猜你喜欢

转载自blog.csdn.net/qq_41185868/article/details/86096013