Search code examples
python-3.xscikit-learnsvmgridsearchcv

GridSearchCV giving " __init__() got an unexpected keyword argument 'fit_params' error


I am running the following piece of code in a jupyter notebook.

from sklearn.svm import LinearSVC
svc_model = LinearSVC()
svc_params = {'C':[0.01,0.1, 1, 10, 100, 1000]}
grid_svc = GridSearchCV(estimator=svc_model,param_grid=svc_params,cv=5,n_jobs=-1)
GridSearchCV(cv=5, error_score='raise-deprecating',
       estimator=LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
                           intercept_scaling=1, loss='squared_hinge', max_iter=1000,
                           multi_class='ovr', penalty='l2', random_state=None, tol=0.0001, verbose=0),
       fit_params=None, iid='warn', n_jobs=-1,
       param_grid={'C': [0.01, 0.1, 1, 10, 100, 1000]},
       pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',
       scoring=None, verbose=0)

Not sure why I am getting this error,

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_20717/2022383170.py in <module>
----> 1 GridSearchCV(cv=5, error_score='raise-deprecating',
      2        estimator=LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
      3      intercept_scaling=1, loss='squared_hinge', max_iter=1000,
      4      multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
      5      verbose=0),

TypeError: __init__() got an unexpected keyword argument 'fit_params'

Can anyone help?


Solution

  • The short answer is that the current version of GridSearchCV does not take an argument called fit_params. This might have been a parameter in an earlier version, I am not sure however.

    What is this parameter supposed to do?

    There also isn't an iid, so you might get a similar error if you remove fit_params.