Created
October 4, 2020 13:37
-
-
Save Davisy/50723578f3b733cb5abf404e4a666db8 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
# define the search space and the objecive function | |
def objective(trial): | |
# Define the search space | |
criterions = trial.suggest_categorical('criterion', ['gini', 'entropy']) | |
max_depths = trial.suggest_int('max_depth', 1, 9, 1) | |
n_estimators = trial.suggest_int('n_estimators', 100, 1000, 100) | |
clf = RandomForestClassifier(n_estimators=n_estimators, | |
criterion=criterions, | |
max_depth=max_depths, | |
n_jobs=-1) | |
score = cross_val_score(clf, X_scaled, y, scoring="accuracy").mean() | |
return score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment