Skip to content

API Accept 'auto' option for 'dual' parameter in LinearSVC and LinearSVR #26093

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 113 commits into from
May 30, 2023

Conversation

glevv
Copy link
Contributor

@glevv glevv commented Apr 5, 2023

Fixes #24651
closes #24731

🤖 Generated by Copilot at cd87daa

Set dual to "auto" for LinearSVC and LinearSVR in some tests to avoid future warnings. This is a temporary fix for compatibility with the upcoming version of scikit-learn.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, I'm doing a git grep -A3 LinearSVC to find instances we're missing, and there are some, eg.:

benchmarks/bench_mnist.py:        Nystroem(gamma=0.015, n_components=1000), LinearSVC(C=100)
benchmarks/bench_mnist.py-    ),
benchmarks/bench_mnist.py-    "SampledRBF-SVM": make_pipeline(
benchmarks/bench_mnist.py:        RBFSampler(gamma=0.015, n_components=1000), LinearSVC(C=100)

examples/miscellaneous/plot_kernel_approximation.py-nystroem_approx_svm = pipeline.Pipeline(
examples/miscellaneous/plot_kernel_approximation.py:    [("feature_map", feature_map_nystroem), ("svm", svm.LinearSVC())]
examples/miscellaneous/plot_kernel_approximation.py-)
examples/miscellaneous/plot_kernel_approximation.py-

examples/model_selection/plot_grid_search_refit_callable.py:        ("classify", LinearSVC(random_state=42, C=0.01)),
examples/model_selection/plot_grid_search_refit_callable.py-    ]
examples/model_selection/plot_grid_search_refit_callable.py-)

examples/model_selection/plot_precision_recall.py:classifier = make_pipeline(StandardScaler(), LinearSVC(random_state=random_state))
examples/model_selection/plot_precision_recall.py-classifier.fit(X_train, y_train)

examples/model_selection/plot_precision_recall.py:    make_pipeline(StandardScaler(), LinearSVC(random_state=random_state))

examples/preprocessing/plot_discretization_classification.py:        make_pipeline(StandardScaler(), LinearSVC(random_state=0)),

...

I haven't checked them all, but I think there's more.

@scikit-learn/core-devs since this is something used so much, I wonder if we want to change the default. WDYT?

@glevv
Copy link
Contributor Author

glevv commented May 8, 2023

Yep, maybe it should be done without changing the default

@glemaitre
Copy link
Member

We previously did similar things for the scale parameter. It will be beneficial in terms of performance, so why not. Deprecations are always annoying.

@glemaitre
Copy link
Member

True that I did not think about changing the examples and benchmark.

@adrinjalali
Copy link
Member

Could you please send a commit with [doc build] in the commit message so that we test the whole doc build as well?

@glevv
Copy link
Contributor Author

glevv commented May 20, 2023

@adrinjalali will do

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

I'm going to give @scikit-learn/core-devs a few days to object here (if any), otherwise happy to merge in a few days.

Thanks for the awesome work @glevv

@adrinjalali adrinjalali merged commit b32e5c7 into scikit-learn:main May 30, 2023
@glevv glevv deleted the linsvm-dual-auto branch May 31, 2023 17:01
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
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.

Default value for solving an SVM in primal and dual should be determined automatically
4 participants