from sklearn.model_selection import GridSearchCV cv = GridSearchCV(rfc,parameters,cv=5) cv.fit(train_features,train_label.values.ravel())