Skip to content

API add option dual="auto" for LinearSVC/LinearSVR #24731

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

Closed
wants to merge 1 commit into from

Conversation

ChidiRnweke
Copy link

Reference Issues/PRs

In reference to issue #24651. The original issue is updated with the relevant benchmarks in the comments.

What does this implement/fix? Explain your changes.

Sets the default value to "auto" and selects if the problem needs to be solved in primal or dual.

Any other comments?

@glemaitre glemaitre changed the title Set primal or dual for LinearSVR/SVC automatically API add option dual="auto" for LinearSVC/LinearSVR Oct 23, 2022
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

In addition, we will need some tests. Since we will run some deprecation, we need to be sure that we raise the proper warning regarding the change of the default in the future.

In addition, we need to check that "auto" does what we expect.

@@ -37,9 +37,11 @@ class LinearSVC(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
square of the hinge loss. The combination of ``penalty='l1'``
and ``loss='hinge'`` is not supported.

dual : bool, default=True
dual : {"auto", False, True}, default= "auto"
Copy link
Member

Choose a reason for hiding this comment

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

I think that we still need to keep the default as-is and make a deprecation cycle to change the default in 1.4

Suggested change
dual : {"auto", False, True}, default= "auto"
dual : "auto" or bool, default=True

Comment on lines +43 to +44
Sets dual = False when n_samples > n_features if dual is "auto"
and dual = True otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Sets dual = False when n_samples > n_features if dual is "auto"
and dual = True otherwise.
`dual="auto"` is equivalent to `dual=False` when
`n_samples > n_features` and `dual=True` otherwise.

optimization problem. Prefer dual=False when n_samples > n_features.
optimization problem.
Sets dual = False when n_samples > n_features if dual is "auto"
and dual = True otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.. versionchanged:: 1.4
The default value will change from `True` to `"auto"` in 1.4.

@@ -210,7 +212,7 @@ def __init__(
penalty="l2",
loss="squared_hinge",
*,
dual=True,
dual="auto",
Copy link
Member

Choose a reason for hiding this comment

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

For making the change for the future, you can check the following documentation: https://scikit-learn.org/dev/developers/contributing.html#change-the-default-value-of-a-parameter

Comment on lines +373 to +374
Sets dual = False when n_samples > n_features if dual is "auto"
and dual = True otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Sets dual = False when n_samples > n_features if dual is "auto"
and dual = True otherwise.
`dual="auto"` is equivalent to `dual=False` when
`n_samples > n_features` and `dual=True` otherwise.
.. versionchanged:: 1.4
The default value will change from `True` to `"auto"` in 1.4.

@@ -362,9 +367,11 @@ class LinearSVR(RegressorMixin, LinearModel):
To lessen the effect of regularization on synthetic feature weight
(and therefore on the intercept) intercept_scaling has to be increased.

dual : bool, default=True
dual : {"auto", False, True}, default= "auto"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dual : {"auto", False, True}, default= "auto"
dual : "auto" or bool, default=True

@glemaitre
Copy link
Member

The CI tell us that we need to modify the _parameter_constraint to show that we accept "auto". We also need to add a hidden option "warn" during the deprecation cycle.

We also need to acknowledge the change in the changelog by adding an entry in doc/whats_new/v1.2.rst.

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

Successfully merging this pull request may close these issues.

3 participants