Created
April 1, 2014 10:52
-
-
Save ajtulloch/9911766 to your computer and use it in GitHub Desktop.
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
| 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