randomizedsearch for random forest classifier

Solutions on MaxInterview for randomizedsearch for random forest classifier by the best coders in the world

showing results for - "randomizedsearch for random forest classifier"
Ivanna
26 Nov 2019
1# create random forest classifier model
2rf_model = RandomForestClassifier()
3
4# set up random search meta-estimator
5# this will train 100 models over 5 folds of cross validation (500 models total)
6clf = RandomizedSearchCV(rf_model, model_params, n_iter=100, cv=5, random_state=1)
7
8# train the random search meta-estimator to find the best model out of 100 candidates
9model = clf.fit(X, y)
10
11# print winning set of hyperparameters
12from pprint import pprint
13pprint(model.best_estimator_.get_params())
14