Skip to content
Advertisement

Make available .best_params_ after pipeline

How to go about making available the clf.best_params_ after carrying a pipeline? For the code I have below, I get an:

AttributeError: 'GridSearchCV' object has no attribute 'best_params_

Here is my code:

JavaScript

Advertisement

Answer

Your clf is never fitted. You probably meant clf.fit(X_train,y_train).

Also, np.linspace(10,50,11) yields floats, while max_depth expects ints, so this may fail and you should probably add a type cast there (like np.linspace(10,50,11).astype('int')) or use something like arange() instead.

You should likely also fix your test set, which currently has no relation with the train one. Last but not least, PCA is not guaranteed to be useful for classification (see e.g. https://www.csd.uwo.ca/~oveksler/Courses/CS434a_541a/Lecture8.pdf).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement