Here's an example of how to perform a grid search for GradientBoostingClassifier in sklearn:
main.py1040 chars31 lines
In this example, we first generate some random classification data for demonstration purposes and split it into training and testing sets. Then we define a parameter grid to search over using param_grid. We initialize a GradientBoostingClassifier model and a GridSearchCV object with the appropriate parameters, and fit the grid search object to the data using fit(). Finally, we print the best parameters and accuracy score found during the grid search using best_params_ and best_score_. Note that n_jobs is set to -1 to use all available cores on the machine.
gistlibby LogSnag