Skip to content

Instantly share code, notes, and snippets.

@amandaiglesiasmoreno
Created November 22, 2021 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandaiglesiasmoreno/909c5fe0ad61e6eb307a3940ce4f118d to your computer and use it in GitHub Desktop.
Save amandaiglesiasmoreno/909c5fe0ad61e6eb307a3940ce4f118d to your computer and use it in GitHub Desktop.
# define the parameter grid
grid_parameters = {'n_estimators': [80, 90, 100, 110, 115, 120],
'max_depth': [3, 4, 5, 6],
'max_features': [None, 'auto', 'sqrt', 'log2'],
'min_samples_split': [2, 3, 4, 5]}
# define the RandomizedSearchCV class for trying different parameter combinations
random_search = RandomizedSearchCV(estimator=GradientBoostingClassifier(),
param_distributions=grid_parameters,
cv=5,
n_iter=150,
n_jobs=-1)
# fitting the model for random search
random_search.fit(X_train, y_train)
# print best parameter after tuning
print(random_search.best_params_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment