scikit learn - Is there easy way to grid search without cross validation in python? -
there absolutely helpful class gridsearchcv in scikit-learn grid search , cross validation, don't want cross validataion. want grid search without cross validation , use whole data train. more specific, need evaluate model made randomforestclassifier "oob score" during grid search. there easy way it? or should make class myself?
the points are
- i'd grid search easy way.
- i don't want cross validation.
- i need use whole data train.(don't want separate train data , test data)
- i need use oob score evaluate during grid search.
i advise against using oob evaluate model, useful know how run grid search outside of gridsearchcv() (i can save cv predictions best grid easy model stacking). think easiest way create grid of parameters via parametergrid() , loop through every set of params. example assuming have grid dict, named "grid", , rf model object, named "rf", can this:
for g in parametergrid(grid): rf.set_params(**g) rf.fit(x,y) if rf.oob_score_ < best_score: best_score = rf.oob_score_ best_grid = g print "oob: %0.5f" % best_score print "grid:", best_grid
Comments
Post a Comment