Skip to content

DOC Fix Matern nu=5/2 formula typo and paired_manhattan_distances off-by-one docstring - #34349

Closed
AYUSHPALLAV1 wants to merge 1 commit into
scikit-learn:mainfrom
AYUSHPALLAV1:fix/doc-matern-52-formula-and-paired-manhattan-offbyone
Closed

AYUSHPALLAV1 wants to merge 1 commit into
scikit-learn:mainfrom
AYUSHPALLAV1:fix/doc-matern-52-formula-and-paired-manhattan-offbyone

Conversation

@AYUSHPALLAV1

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #34315
Fixes #34283

What does this implement/fix?

Fix 1 — Off-by-one in paired_manhattan_distances docstring (#34315)

The docstring described the last computed pair as (X[n_samples], Y[n_samples]), which would raise IndexError in Python. Valid indices for an array of n_samples elements are 0 to n_samples - 1. Updated to (X[n_samples - 1], Y[n_samples - 1]).

Fix 2 — Missing exponent in Matern kernel nu=5/2 formula (#34283)

The closed-form Matern nu=5/2 formula in doc/modules/gaussian_process.rst had a typo in the quadratic term:

  • Incorrect: 5 / (3l) * d^2
  • Correct: 5 / (3l^2) * d^2

This is consistent with:

  • Rasmussen & Williams (2006), p. 84 (the referenced source)
  • The kernels.py implementation: K = dists * sqrt(5) (already divided by l), then K**2 / 3.0, which expands to 5/(3l^2) * d^2

First time contributor introduction

I am an ML student who uses scikit-learn extensively for research in Gaussian Processes and metric learning. I found these issues while studying the source code and documentation.

AI usage disclosure

I used AI-assisted tooling to verify the mathematical correctness against the reference implementation and the Rasmussen & Williams textbook.

Fix off-by-one indexing in paired_manhattan_distances docstring (scikit-learn#34315):
The docstring described distances as computed up to (X[n_samples], Y[n_samples]),
which is an IndexError in Python. Corrected to (X[n_samples - 1], Y[n_samples - 1])
to accurately reflect 0-based indexing.

Fix missing square in Matern nu=5/2 formula in user guide (scikit-learn#34283):
The closed-form expression for the Matern kernel with nu=5/2 had a typo:
the quadratic term read 5/(3l)*d^2 but should be 5/(3l^2)*d^2, consistent
with Rasmussen & Williams (2006) p.84 and the actual implementation in kernels.py.
@github-actions

Copy link
Copy Markdown

Thank you for opening your first pull request to scikit-learn! 🎉

To help get your contribution reviewed, please make sure that:

  • You have filled out the pull request template.
  • The pull request addresses an existing issue that is ready for
    contribution (e.g. not tagged as "Needs Triage", "Needs Decision", ...).
    If you are proposing a new feature, please open an issue to discuss it first.
  • There are no other open pull requests already targeting the same issue.
  • You have followed the pull request checklist.
    In particular, linting and tests should pass.

@virchan virchan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your interest in contributing to scikit-learn, @AYUSHPALLAV1.

The changes appear to be largely automated, and do not show sufficient human review. With that said, I'm closing this PR as spam.

If you'd like to contribute to scikit-learn meaningfully, please review the following resources first:

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.

Off-by-one indexing error in paired_manhattan_distances docstring

2 participants