Created
July 11, 2012 12:17
-
-
Save pprett/3090011 to your computer and use it in GitHub Desktop.
Simple and stupid benchmark for sklearn DecisionTreeRegressor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 clf.fit(X, y)" | |
boston = datasets.load_boston() | |
X, y = boston.data, boston.target | |
clf = DecisionTreeRegressor(max_depth=20) | |
%timeit clf.fit(X, y) | |
%timeit clf.predict(X) | |
clf = DecisionTreeRegressor(max_depth=1) | |
%timeit clf.fit(X, y) | |
%timeit clf.predict(X) | |
clf = RandomForestRegressor() | |
%timeit clf.fit(X, y) | |
%timeit clf.predict(X) | |
clf = gradient_boosting.GradientBoostingRegressor(n_estimators=250, | |
max_depth=1, | |
learn_rate=1.0) | |
%timeit clf.fit(X, y) | |
%timeit clf.predict(X) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment