Background of the Problem
I was trying to use a KerasRegressor model with the ML models (e.g. Lasso, Gradient Boost Regressor) for the purpose of building an ensemble method. I used the VotingRegressor() function of sklearn to group the models. However, when I add the KerasRegressor model in VotingRegressor(), I get the following error.
ValueError: The estimator KerasRegressor should be a regressor.
How Did I Try to Solve the Problem?
I searched on google by the error and I found only this page where I do not find the solution. Moreover, I tried to understand the document of the KerasRegressor. However, I do not know why I get the error as the document says that it is the implementation of the scikit-learn regressor API for Keras.
Then, My Question
Why did I get the error and what can I do to solve it?
Any help will be greatly appreciated :). Thanks!
From this issue there is no solution using keras as sklearn wrapper is not maintained and will be removed
Fortunately scikeras package solve this issue.
I advice you to read docs or tutorials but here a simple example using subclassing: