EL之RF(随机性的Bagging+DTR):利用随机选择属性的bagging方法解决回归(对多变量的数据集+实数值评分预测)问题
生活随笔
收集整理的这篇文章主要介绍了
EL之RF(随机性的Bagging+DTR):利用随机选择属性的bagging方法解决回归(对多变量的数据集+实数值评分预测)问题
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
EL之RF(随机性的Bagging+DTR):利用随机选择属性的bagging方法解决回归(对多变量的数据集+实数值评分预测)问题
目录
输出结果
设计思路
核心代码
输出结果
设计思路
核心代码
for iTrees in range(numTreesMax):modelList.append(DecisionTreeRegressor(max_depth=treeDepth))#第一个随机:随机抽取属性样本 idxAttr = random.sample(range(ncols), nAttr)idxAttr.sort()indexList.append(idxAttr)#第二个随机:随机抽取训练行样本idxRows = []for i in range(int(0.5 * nTrainRows)):idxRows.append(random.choice(range(len(xTrain))))idxRows.sort()xRfTrain = []yRfTrain = []for i in range(len(idxRows)):temp = [xTrain[idxRows[i]][j] for j in idxAttr]xRfTrain.append(temp)yRfTrain.append(yTrain[idxRows[i]])modelList[-1].fit(xRfTrain, yRfTrain)xRfTest = []for xx in xTest:temp = [xx[i] for i in idxAttr]xRfTest.append(temp)latestOutSamplePrediction = modelList[-1].predict(xRfTest)predList.append(list(latestOutSamplePrediction))
总结
以上是生活随笔为你收集整理的EL之RF(随机性的Bagging+DTR):利用随机选择属性的bagging方法解决回归(对多变量的数据集+实数值评分预测)问题的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: EL之Boosting之GB(DTR):
- 下一篇: EL之RF(RFR):利用RandomF