Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for some of the regression models #116

Open
Mojzaar opened this issue Mar 22, 2023 · 1 comment
Open

Error for some of the regression models #116

Mojzaar opened this issue Mar 22, 2023 · 1 comment

Comments

@Mojzaar
Copy link

Mojzaar commented Mar 22, 2023

I was going to use PiecewiseRegressor with ARDRegression estimator, and in general an estimator build with a pipeline or Gridsearch model but I am getting this error:
Traceback (most recent call last): File "<ipython-input-37-ef69b6e34e02>", line 1, in <module> model.fit(sf.X_train,sf.y_train) File "/usr/local/lib/python3.8/dist-packages/mlinsights/mlmodel/piecewise_estimator.py", line 250, in fit self.mean_estimator_ = clone(self.estimator).fit(X, y, sample_weight) TypeError: fit() takes 3 positional arguments but 4 were given

While PiecewiseRegressor works fine with other models like Ridge, Lasso and LinearRegression. Any idea what is going wrong here?

P.S: It appears some regression models and GS models do not accept the "sample_weight" parameter, so giving it to the estimator throws this error. So, in piecewise_estimator code, if one checks weather the estimator's fit function has "sample_weight" parameter by:
self.mean_estimator_ = clone(self.estimator).fit(X, y, sample_weight) if 'sample_weight' in list(self.estimator.fit.__code__.co_varnames) else clone(self.estimator).fit(X, y)
the problem is solved!

@Mojzaar Mojzaar changed the title Error for ARDRegression Error for some of the regression models Mar 22, 2023
@sdpython
Copy link
Owner

sdpython commented Sep 7, 2024

I'm sorry. I don't actively work on this package. Do you have an example I could use to replicate the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants