Skip to content

ENH Warn on irrelevant parameters for linear kernel in SVC #30174

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

lamdang2k
Copy link
Contributor

@lamdang2k lamdang2k commented Oct 29, 2024

Reference Issues/PRs

closes #28641
closes #19630
Fixes #19614

What does this implement/fix? Explain your changes.

Add user warnings when irrelevant parameters are set for linear kernel

Any other comments?

Copy link

github-actions bot commented Oct 29, 2024

✔️ Linting Passed

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

Generated for commit: 9c86ec2. Link to the linter CI: here

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.

This also would need tests, a starting point was provided in #19630

@lamdang2k lamdang2k requested a review from adrinjalali November 6, 2024 12:41
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.

we also need a commit with a [doc build] in the commit message to make sure our docs don't raise these errors.

@@ -217,7 +217,25 @@ def fit(self, X, y, sample_weight=None):
"X and y have incompatible shapes.\n"
+ "X has %s samples, but y has %s." % (n_samples, y.shape[0])
)

if self.kernel == "linear":
if self.gamma != "scale":
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 it's odd to check for the default value here, since the user might be setting these default values explicitly. One alternative is to have the default value as None, and here check if it's None.

Then it begs the question, do we automatically assign a default value to gamma when it's None or not. As a consequence, the question becomes, should this be valid code?

SVC(kernel="rbf")

Or should the user always give a gamma as:

SVC(kernel="rbf", gamma=.1)

@adam2392 or @ogrisel might have opinions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adrinjalali I think it's better to require a value of gamma to be clearly specified. Since the default value is already None, we might not want to have another default value when None is chosen. For me it's strange to have two default values for a single function call.

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.

Give feedback when svm.SVC is configured with kernel hyperparameters for a different kernel
3 participants