I have a problem when using the SVC model with optimized parameters by GridSearch for prediction. It tells me "GridSearchCV' object has no attribute 'best_estimator_'".
I have tried with scikit-learn 0.14 installed via PIP and scikit-learn 0.15 installed from source and obtained the same error.
Code snippet:
parameters = {'gamma': np.logspace(-10, -8, 30),'C': np.logspace(6, 7, 40)}
svm1=GridSearchCV(svm.SVC(), parameters, verbose=1, refit=False, cv=3, n_jobs=4).fit(X_train, y_train)
svm1.predict(X_test)
error message:
/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/grid_search.pyc in predict(self)
326 @Property
327 def predict(self):
--> 328 return self.best_estimator_.predict
329
330 @Property
AttributeError: 'GridSearchCV' object has no attribute 'best_estimator_'