Skip to content

MNT better error message in RidgeCV #19020

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

Merged
merged 2 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sklearn/linear_model/_ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ def fit(self, X, y, sample_weight=None):

if np.any(self.alphas <= 0):
raise ValueError(
"alphas must be positive. Got {} containing some "
"alphas must be strictly positive. Got {} containing some "
"negative or null value instead.".format(self.alphas))

X, y, X_offset, y_offset, X_scale = LinearModel._preprocess_data(
Expand Down
4 changes: 2 additions & 2 deletions sklearn/linear_model/tests/test_ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,13 +1126,13 @@ def test_ridgecv_negative_alphas():
# Negative integers
ridge = RidgeCV(alphas=(-1, -10, -100))
assert_raises_regex(ValueError,
"alphas must be positive",
"alphas must be strictly positive",
ridge.fit, X, y)

# Negative floats
ridge = RidgeCV(alphas=(-0.1, -1.0, -10.0))
assert_raises_regex(ValueError,
"alphas must be positive",
"alphas must be strictly positive",
ridge.fit, X, y)


Expand Down