Title: Random Forest Regression
Slug: random_forest_regression
Summary: Training a random forest regressor in scikit-learn.
Date: 2017-09-21 12:00
Category: Machine Learning
Tags: Trees And Forests
Authors: Chris Albon
In [4]:
# Load libraries
from sklearn.ensemble import RandomForestRegressor
from sklearn import datasets
In [5]:
# Load data with only two features
boston = datasets.load_boston()
X = boston.data[:,0:2]
y = boston.target
In [6]:
# Create decision tree classifer object
regr = RandomForestRegressor(random_state=0, n_jobs=-1)
In [7]:
# Train model
model = regr.fit(X, y)