def grid_search_cv(clf, x, y, params, cv = 5):
"""
:param clf: The classifier over which we want to perform
gridsearch.
:param x: Features
:param y: Target
:param params: Hyperparameters to perform gs on
:cv: kfold cv parameter
"""
gs = GridSearchCV(clf, param_grid = params, cv = cv)
gs.fit(x, y)
print
print 'BEST PARAMS:', gs.best_params_
print 'BEST SCORE:', gs.best_score_
print
best_estimator = gs.best_estimator_
return best_estimator
######################
# PREPARING THE DATA #
######################
#get the last 4 images from each file
评论列表
文章目录