8000 Add option gamma='scale' and 'auto' to RBFSampler · Issue #24748 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Add option gamma='scale' and 'auto' to RBFSampler #24748

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
glevv opened this issue Oct 24, 2022 · 3 comments · Fixed by #24755
Closed

Add option gamma='scale' and 'auto' to RBFSampler #24748

glevv opened this issue Oct 24, 2022 · 3 comments · Fixed by #24755
Assignees

Comments

@glevv
Copy link
Contributor
glevv commented Oct 24, 2022

Describe the workflow you want to enable

Right now SVM supports gamma parameter to be set to 'scale' or 'auto', which will automatically determine gamma parameter based on data, but RBFSampler does not support this.

On top of that there is no check on n_components parameter, which allow users to set it to 0 and fit it without errors. It will only raise error if n_components is negative - ValueError: negative dimensions are not allowed (this is numpy error from random.normal generation, not sklearn one).

Describe your proposed solution

Add 'scale' and 'auto' option to RBFSampler

Describe alternatives you've considered, if relevant

It is possible to calculate gamma beforehand on your own, but it become increasingly tiresome if for example someone is performing CV - you will have to use custom loop instead of cross_val_score and others.

Additional context

No response

@glevv glevv added Needs Triage Issue requires triage New Feature labels Oct 24, 2022
@glemaitre
Copy link
Member

On top of that there is no check on n_components parameter, which allow users to set it to 0 and fit it without errors. It will only raise error if n_components is negative - ValueError: negative dimensions are not allowed (this is numpy error from random.normal generation, not sklearn one).

This should not be the case in main since we introduce the parameter constraints:

_parameter_constraints: dict = {
"gamma": [Interval(Real, 0, None, closed="left")],
"n_components": [Interval(Integral, 1, None, closed="left")],
"random_state": ["random_state"],
}

Regarding the proposal of adding the str option, I think that it could be nice to have the "scale" option. I don't know if the option "auto" is actually a good idea. Reading the change of default in the past (#8361), we would have probably not introduced it at first.

@glemaitre glemaitre removed the Needs Triage Issue requires triage label Oct 25, 2022
@glevv
Copy link
Contributor Author
glevv commented Oct 25, 2022

If Needs Triage tag is removed, it's free to draft a PR?

@glemaitre
Copy link
Member

If Needs Triage tag is removed, it's free to draft a PR?

Yep. We would still need to have another reviewer to review the PR but otherwise it should be fine.

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

Successfully merging a pull request may close this issue.

2 participants
0