random forests hyperparameter tuning
from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import classification_report from sklearn.model_selection import GridSearchCV import numpy as np X_train, X_test, y_train, y_test = train_test_split(df, y, test_size=0.25, random_state=42) scaler = MinMaxScaler() X_train = scaler.fit_transform(X_train) X_test = scaler.transform(X_test) model = RandomForestClassifier() param_grid = {'n_estimators':[200,250], 'max_depth':[3,5,7], 'min_samples_leaf':[3,5,10], 'min_samples_split':[8,10,12], 'criterion':['gini','entropy']} gridsearchcv = GridSearchCV(model, param_grid, cv = 3, verbose=True, n_jobs=-1) best_parameters = gridsearchcv.fit(X_train, y_train) best_parameters