Applying the Random Forest model to a regression analysis
Random Forest, similar to decision trees, can also be applied to solving regression problems. We used them previously to classify calls (refer to the Predicting subscribers with random tree forests recipe in Chapter 3, Classification Techniques). Here, we will use Random Forest to predict the output of a power plant.
Getting ready
To execute this, you will need pandas
, NumPy
, and Scikit
. No other prerequisites are required.
How to do it…
The Random Forests are part of the ensemble types of models. This example borrows the code-shell that we presented in Chapter 3, Classification Techniques (the regression_randomForest.py
file):
import sys sys.path.append('..') # the rest of the imports import helper as hlp import pandas as pd import numpy as np import sklearn.ensemble as en import sklearn.cross_validation as cv @hlp.timeit def regression_rf(x,y): ''' Estimate a random forest regressor ''' # create the regressor object...