# Hyperparameter tuning with CV (pseudocode)
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestClassifier
param_grid = {"n_estimators": [100,200,500],
"max_depth": [5,10,None],
"min_samples_split": [2,5,10]}
rf = RandomForestClassifier(class_weight="balanced")
cv = GridSearchCV(rf, param_grid, cv=5, scoring="f1")
cv.fit(X_train, y_train)
print(cv.best_params_, cv.best_score_)