TypeError grid search

后端 未结 1 695
挽巷
挽巷 2021-01-22 15:27

I used to create loop for finding the best parameters for my model which increased my errors in coding so I decided to use GridSearchCV.
I am trying to find ou

相关标签:
1条回答
  • 2021-01-22 15:45

    You are supplying 'all' as a param in SelectKBest. But according to the documentation, if you want to pass 'all', you need to specify it as:

    SelectKBest(k='all')
    

    The reason is that its a keyword argument, it should be specified with the keyword. Because the first argument to SelectKBest is a positional argument for the scoring function. So when you do not specify the param, 'all' is considered an input for the function and hence the error.

    Update:

    Now about the shape, the original X will not be changed. So it will print (150,4). The data will be changed on the fly and on my pc the best_param_ is n_components=1, so final shape that goes to svm is (150, 5), 1 from PCA and 4 from SelectKBest.

    0 讨论(0)
提交回复
热议问题