v Random Forest Regression - Machine Learning

Random Forest Regression

Preliminaries

# Load libraries
from sklearn.ensemble import RandomForestRegressor
from sklearn import datasets

Load Boston Housing Data

# Load data with only two features
boston = datasets.load_boston()
X = boston.data[:,0:2]
y = boston.target

Create Random Forest Regressor

# Create decision tree classifer object
regr = RandomForestRegressor(random_state=0, n_jobs=-1)

Train Random Forest Regressor

# Train model
model = regr.fit(X, y)