Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@glemaitre
Copy link
Member

closes #29772

Solve a regression in SVC and SVR were we previously accepted C=float("inf").

@github-actions
Copy link

github-actions bot commented Sep 3, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: b36c745. Link to the linter CI: here

@glemaitre glemaitre added this to the 1.5.2 milestone Sep 3, 2024
Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks @glemaitre

I don't think the CI failures look related as they seem to be occurring elsewhere too.

@glemaitre
Copy link
Member Author

Yep the failure is tracked there: #29771

@OmarManzoor OmarManzoor added Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one! labels Sep 4, 2024
@lesteve
Copy link
Member

lesteve commented Sep 4, 2024

Not sure this is worth doing to be honest (LogisticRegression accept C=float('infinity') and has a test for it so I guess this is some kind of precedent?) ...

If we do it we may as well do it for LinearSVR and LinearSVC:

❯ git grep -p -P 'C":.+Inter'
sklearn/linear_model/_logistic.py=class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
sklearn/linear_model/_logistic.py:        "C": [Interval(Real, 0, None, closed="right")],
sklearn/linear_model/_passive_aggressive.py=class PassiveAggressiveClassifier(BaseSGDClassifier):
sklearn/linear_model/_passive_aggressive.py:        "C": [Interval(Real, 0, None, closed="right")],
sklearn/linear_model/_passive_aggressive.py=class PassiveAggressiveRegressor(BaseSGDRegressor):
sklearn/linear_model/_passive_aggressive.py:        "C": [Interval(Real, 0, None, closed="right")],
sklearn/svm/_base.py=class BaseLibSVM(BaseEstimator, metaclass=ABCMeta):
sklearn/svm/_base.py:        "C": [Interval(Real, 0.0, None, closed="neither")],
sklearn/svm/_classes.py=class LinearSVC(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
sklearn/svm/_classes.py:        "C": [Interval(Real, 0.0, None, closed="neither")],
sklearn/svm/_classes.py=class LinearSVR(RegressorMixin, LinearModel):
sklearn/svm/_classes.py:        "C": [Interval(Real, 0.0, None, closed="neither")],

@glemaitre
Copy link
Member Author

I'll do for the other class.

Not sure this is worth doing to be honest

If it would not be a regression and that we never tolerated it, I would not make the change. But the fact that we introduced this small regression is a bit annoying :)

@ogrisel
Copy link
Member

ogrisel commented Sep 4, 2024

And it's good to be able to explore the unregularized limit if the underlying solver can support it. Although in practice, it should be very similar to C=1e30 or so in most cases.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ogrisel ogrisel enabled auto-merge (squash) September 4, 2024 13:53
@glemaitre
Copy link
Member Author

@lesteve I quickly check what happen when setting C=float("inf") in LinearSVC and LinearSVR. It does seem to work: the computation never end and I had to kill the kernel, so we should be in the C code. I also make sure to reduce the number of iteration but still the same.

So this is probably not a good idea to tolerate this for both LinearSVM.

@ogrisel ogrisel merged commit 3b39d7c into scikit-learn:main Sep 4, 2024
glemaitre added a commit to glemaitre/scikit-learn that referenced this pull request Sep 9, 2024
glemaitre added a commit that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:svm Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C regularization parameter error when assigned infinity

4 participants