scikit-learn / scikit-learn/scikit-learn

Data type of degree parameter for polynomial kernels

Open
#14,186 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement module:metrics Needs Decision - Include Feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.