Created
May 13, 2021 21:43
-
-
Save harrywang/afd9f7fc714ac992dad139d69161f701 to your computer and use it in GitHub Desktop.
ensemble learning hints
This file contains 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
# partial code snippets shown as hints | |
# voting regressor | |
from sklearn.ensemble import VotingRegressor | |
voting_reg = VotingRegressor( | |
estimators = [ | |
('lin', lin_reg_pipeline), | |
('svm', svm_reg_pipeline), | |
('sgd', sgd_reg_pipeline), | |
], | |
) | |
# random forest regressor and tuning parameters | |
from sklearn.ensemble import RandomForestRegressor | |
rf_pipeline = Pipeline( | |
steps=[ | |
('preprocessor', preprocessor), | |
('rf', RandomForestRegressor()), | |
] | |
) | |
param_grid = [ | |
{ | |
'rf__n_estimators': [50, 100, 200, 300], | |
'rf__max_depth': [2, 3, 5, 10, 20], | |
} | |
] | |
# GBRT example | |
from sklearn.ensemble import GradientBoostingRegressor | |
gb_pipeline = Pipeline( | |
steps=[ | |
('preprocessor', preprocessor), | |
('gb', GradientBoostingRegressor()), | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment