Grid Search

# Entropy
import time
parameters = {'max_depth': [3, None],
              'max_features': [1, 5, 10],
              'min_samples_split': [2, 5, 10],
              'min_samples_leaf': [1, 5, 10],
              'bootstrap': [True, False],
              'criterion': ['entropy']}

from sklearn.model_selection import GridSearchCV

grid_search = GridSearchCV(estimator = model,
                           param_grid = parameters,
                           scoring = 'accuracy',
                           cv = 10)

t0 = time.time()
grid_search = grid_search.fit(X_train, y_train)
t1 = time.time()
print('Took %0.2f seconds' % (t1 - t0))

rf_best_accuracy = grid_search.best_score_
rf_best_parameters = grid_search.best_params_
rf_best_accuracy, rf_best_parameters

print('best accuracy', rf_best_accuracy)
print('best parameters', rf_best_parameters)
# Gini
parameters = {'max_depth': [3, None],
              'max_features': [1, 5, 10],
              'min_samples_split': [2, 5, 10],
              'min_samples_leaf': [1, 5, 10],
              'bootstrap': [True, False],
              'criterion': ['gini']}

from sklearn.model_selection import GridSearchCV

grid_search = GridSearchCV(estimator = model,
                           param_grid = parameters,
                           scoring = 'accuracy',
                           cv = 10)

t0 = time.time()
grid_search = grid_search.fit(X_train, y_train)
t1 = time.time()
print('Took %0.2f seconds' % (t1 - t0))

rf_best_accuracy = grid_search.best_score_
rf_best_parameters = grid_search.best_params_
rf_best_accuracy, rf_best_parameters

print('best accuracy', rf_best_accuracy)
print('best parameters', rf_best_parameters)