Last active
July 30, 2020 03:40
-
-
Save vanbrands/190947d2e042201010001660036eca50 to your computer and use it in GitHub Desktop.
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
from sklearn.preprocessing import KBinsDiscretizer | |
from sklearn.model_selection import RandomizedSearchCV | |
search_space = { | |
'preprocessing__binfeatures__n_bins': [10, 20], | |
'model__n_estimators': [500, 1000, 2000], | |
'model__class_weight': ['balanced', 'balanced_subsample'] | |
} | |
preprocessing = ColumnTransformer(transformers=[ | |
('binfeatures', KBinsDiscretizer(), ['numerical_feature']) | |
]) | |
pipeline = Pipeline(steps=[ | |
('preprocessing', preprocessing), | |
('model', RandomForestClassifier()) | |
]) | |
search = RandomizedSearchCV(pipeline, search_space, cv=5) | |
search.fit(x, y) | |
search.best_estimator_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment