Created
October 3, 2020 14:14
-
-
Save Davisy/13d1eff95ab08f58bb5f99bd57c4848c 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
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 = sklearn.ensemble.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