Give feedback when `svm.SVC` is configured with kernel hyperparameters for a different kernel
See original GitHub issueDuring our class we noticed some students incorrectly configure some hyperparameters which are irrelevant to the kernel used, for example setting gamma
when using a linear kernel. We think it could make sense for scikit-learn to give feedback to the user when non-effective settings are configured.
Describe the workflow you want to enable
from sklearn.datasets import load_iris
from sklearn.svm import SVC
x, y = load_iris(return_X_y=True)
clf = SVC(kernel='linear', gamma=1e-6)
clf.fit(x, y)
print(clf.score(x, y))
current output:
0.9933333333333333
proposed output, something similar to:
UserWarning: Gamma is set but not used because a linear kernel is configured.
0.9933333333333333
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (18 by maintainers)
Top Results From Across the Web
KNN-SVM-SVM with Kernel-Hyperparameter - Kaggle
SVC Implementation is based on libsvm(library for Support Vector Machines). C is the Regularization parameter in SVC and its float with default value...
Read more >SVM and Kernel SVM - Towards Data Science
In this article, you will learn about SVM or Support Vector Machine, which is one of the most ... classifier = SVC(kernel =...
Read more >sklearn.svm.SVC — scikit-learn 1.2.0 documentation
Specifies the kernel type to be used in the algorithm. If none is given, 'rbf' will be used. If a callable is given...
Read more >Simple Tutorial on SVM and Parameter Tuning in Python and R
It follows a technique called the kernel trick to transform the data ... We can see that it is possible to separate the...
Read more >Support Vector Machine (SVM) Hyperparameter Tuning In ...
The default kernel function for the python implementation of the support vector classifier is the Radial Basis Function, which is usually referred to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll update the PR when there is a new consensus (the PR has a
FutureWarning
instead ofDeprecationWarning
right now) 😃 just let me knowthe validation should happen in
fit
(more details here if you’re interested https://scikit-learn.org/stable/developers/develop.html#instantiation)Also please make sure to write a non-regression test for the cases that are worth testing. The test should make sure that the error is now properly raised. Your snippet above is a great candidate.
Thanks!