What is random forest regression?
Random forest regression is a type of ensemble learning, which is the process of using multiple models, trained over the same data, averaging the results of each model to ultimately find a more powerful predictive/classification result.
The process of making a random forest regression
- Step 1: Pick at random K data points from the Training set.
- Step 2: Build the decision tree associated with these K data points.
- Step 3: Choose the number of trees you want to build and repeat steps 1 and 2.
- Step 4: For a new data point, make each one of your trees predict the value of Y for the data point in question. Then, assign the new data point the average of all the predicted Y values.
Example
Code
1
2
3
4
from sklearn.tree import DecisionTreeRegressor
regressor = DecisionTreeRegressor()
regressor.fit(X, y)
regressor.predict(X)