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
With sklearn Version 0.22.1 a linear regression with negative sample weights fails with the following (unclear) error message.
Would be helpful if (e.g. _check_sample_weight) checks for negative weights and raises an appropriate error message.
File "C:\Users\gm889704\.conda\envs\gm\lib\site-packages\sklearn\pipeline.py", line 354, in fitself._final_estimator.fit(Xt, y, **fit_params)
File "C:\Users\gm889704\.conda\envs\gm\lib\site-packages\sklearn\linear_model\_base.py", line 533, in fit
linalg.lstsq(X, y)
File "C:\Users\gm889704\.conda\envs\gm\lib\site-packages\scipy\linalg\basic.py", line 1157, in lstsq
a1 = _asarray_validated(a, check_finite=check_finite)
File "C:\Users\gm889704\.conda\envs\gm\lib\site-packages\scipy\_lib\_util.py", line 246, in _asarray_validated
a = toarray(a)
File "C:\Users\gm889704\.conda\envs\gm\lib\site-packages\numpy\lib\function_base.py", line 499, in asarray_chkfinite"array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs
The text was updated successfully, but these errors were encountered:
We could add a parameter only_positive that will be a boolean in _check_sample_weight.
By default, it would be False to be backward compatible and we can it to True and raise an error for negative weight in the estimator where it makes sense (I recall that we did something like this in AdaBoost).
With sklearn Version 0.22.1 a linear regression with negative sample weights fails with the following (unclear) error message.
Would be helpful if (e.g.
_check_sample_weight
) checks for negative weights and raises an appropriate error message.The text was updated successfully, but these errors were encountered: