Skip to content

Instantly share code, notes, and snippets.

@ajtulloch
Created April 1, 2014 10:52
Show Gist options
  • Select an option

  • Save ajtulloch/9911766 to your computer and use it in GitHub Desktop.

Select an option

Save ajtulloch/9911766 to your computer and use it in GitHub Desktop.
from sklearn import ensemble, datasets, cross_validation
from sklearn.utils.testing import assert_array_almost_equal
from compiledtrees import CompiledRegressionPredictor
# Generate dataset
X, y = datasets.make_friedman1(n_samples=1000, n_features=50)
X_train, X_test, y_train, y_test = \
cross_validation.train_test_split(X, y, test_size=0.2)
# Fit the regressor
clf = ensemble.GradientBoostingRegressor(n_estimators=100)
clf.fit(X_train, y_train)
# Compile predictor and verify correctness
compiled_clf = CompiledRegressionPredictor(clf)
assert_array_almost_equal(clf.predict(X_test), compiled_clf.predict(X_test),
decimal=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment