You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
Mojzaar
changed the title
Error for ARDRegression
Error for some of the regression models
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!
The text was updated successfully, but these errors were encountered: