Skip to content

Instantly share code, notes, and snippets.

@pprett pprett/
Created Jul 11, 2012

What would you like to do?
Simple and stupid benchmark for sklearn DecisionTreeRegressor
import numpy as np
from sklearn import datasets
from sklearn.ensemble import gradient_boosting
from sklearn.ensemble import RandomForestClassifier,RandomForestRegressor
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
X, y = datasets.make_hastie_10_2(n_samples=12000, random_state=1)
X = X.astype(np.float32)
print "%timeit, y)"
boston = datasets.load_boston()
X, y =,
clf = DecisionTreeRegressor(max_depth=20)
%timeit, y)
%timeit clf.predict(X)
clf = DecisionTreeRegressor(max_depth=1)
%timeit, y)
%timeit clf.predict(X)
clf = RandomForestRegressor()
%timeit, y)
%timeit clf.predict(X)
clf = gradient_boosting.GradientBoostingRegressor(n_estimators=250,
%timeit, y)
%timeit clf.predict(X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.