《Machine Learning A-Z》Part 2 (6) - Random Forest Regression

随机森林回归是一种集成学习方法,通过结合多个决策树的预测来提高模型的准确性和稳定性。该方法包括随机选择训练数据子集构建决策树,然后对新数据点的预测值取平均以得出最终预测。在给定的示例中,使用sklearn库的RandomForestRegressor进行训练,并对新数据进行预测。
摘要由CSDN通过智能技术生成

12.08.2021

Random Forest Regression

Random Forest Learning is a version of Ensemble Learning, there are also other version such as gradient boosting. Ensemble Learning is you take multiple algorithms or an algorithm multiple times and you put them together to make something much more powerful than it was. 

Step 1. 

Pick at random K data points from the training dataset.

Step 2.

Build the Decision tree associated to these K data points.

Step 3.

Choose the number of Ntree of trees you want to build and repeat steps 1&2

Step 4. 

For a new data point, make each one of your Ntree trees predict the value of Y to for the data point in question, and assign the new data point the average across all of the predicted Y values.

- Training the Random Forest Regression model on the whole dataset

from sklearn.ensemble import RandomForestRegressor
regressor = RandomForestRegressor(n_estimators = 10, random_state = 0)
regressor.fit(X, y)

- Predicting a new result

regressor.predict([[6.5]])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值