Skip to content
Advertisement

TypeError: fit() missing 1 required positional argument: ‘y’,

I want to try out all regressors within the library. Since I do know, that some of the regressors require more input I build the try and expept catch block.

JavaScript

This returns the following snipped many times:

JavaScript

In my opinion there are two problems here. First, exept never gets called. Second, the y input is not recognized.

I am gratefull for any kind of help.

Advertisement

Answer

all_estimators does not return instances of estimators but only their classes (see the documentation). When defining the pipeline, you should instantiate an object of that class:

JavaScript

Note the () after estimator. Now you have actual objects that can be fitted to data.


Concerning the except block: by default, cross_validate will just assign np.nan to the score if an error occurs. To actually raise the error, set error_score='raise' in cross_validate:

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