scikit-learn / scikit-learn/scikit-learn
Data type of degree parameter for polynomial kernels
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 67.3k
- Forks
- 27.4k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 58
Description
According to the docs, the degree parameter for a metrics.pairwise.polynomial_kernel (and, e.g., also for a decomposition.KernelPCA or a svm.SVR) module should be int ([1], [2], [3]).
Mathematically, fractional values for the degree make things a little more complicated; however, the resulting kernels seem to enjoy some interesting properties, because they effectively map into an infinitely-dimensional space (just like, e.g., RBF kernels). Furthermore, from a technical point of view, the actual polynomial_kernel function never really makes use of the assumption that degree is an integer anyway (the **= operation works for both floats and integers), and in practice, a float value for degree already seems to work just fine.
I was therefore wondering if there is a particular reason why the documentation calls for an integer for the degree parameter, or whether this is unintentional and the docs can / should be updated? :) In the latter case, I'd be happy to try and submit a PR.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the linked documentation for polynomial_kernel, KernelPCA, and SVR, then inspect sklearn/metrics/pairwise.py around the referenced polynomial_kernel implementation. First determine whether fractional degree values are intentionally supported and consistent across these APIs. Done means the documentation and any related parameter validation agree with the resolved behavior, with focused tests or documentation checks if the project requires them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation, machine-learning
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100