Skip to content

[Feature] Local kNN dimension estimator#38

Merged
Xmaster6y merged 4 commits intomainfrom
local-knn
Feb 13, 2026
Merged

[Feature] Local kNN dimension estimator#38
Xmaster6y merged 4 commits intomainfrom
local-knn

Conversation

@Xmaster6y
Copy link
Owner

@Xmaster6y Xmaster6y commented Feb 13, 2026

What does this PR do?

Key insights about the PR.

Linked Issues

  • Closes #?
  • #?

Checklist

  • I have read the CONTRIBUTING guide.
  • I have added tests for my changes if needed.
  • I have updated the documentation if needed.

Summary by cubic

Add a per-point local intrinsic dimension estimator using k-NN distances, plus a shared neighbor-distance utility now used by TwoNn for consistent filtering and duplicate handling. Docs now cite Farahmand et al. (2007).

  • New Features

    • LocalKnnDimensionEstimator(k | "auto") computes d(x) = ln(2) / ln(R2k/Rk); validates k, requires N ≥ 2k+1, and ignores self/≤eps neighbors.
    • Supports (N, D) and (..., N, D); outputs (..., N). Configurable in_key/out_key and eps. Exported in tdhook.latent and tdhook.latent.dimension_estimation; tests cover batch/custom keys, determinism, known manifolds, auto-k, and error cases.
  • Refactors

    • Added sorted_neighbor_distances in _utils and switched TwoNnDimensionEstimator to use it to reduce duplication and unify neighbor filtering.
    • Added ICML '07 citation (Farahmand–Szepesvári–Audibert) to references.

Written for commit 42463fb. Summary will update on new commits.

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.71%. Comparing base (975080d) to head (42463fb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   96.61%   96.71%   +0.09%     
==========================================
  Files          31       33       +2     
  Lines        1980     2038      +58     
==========================================
+ Hits         1913     1971      +58     
  Misses         67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Adds a new intrinsic dimension estimator with tests, uses small focused changes, no sensitive or critical logic touched.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="docs/source/references.bib">

<violation number="1" location="docs/source/references.bib:238">
P3: The conference location is misspelled; ICML 2007 was in Corvallis, Oregon. Correcting the metadata avoids citation inaccuracies.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Xmaster6y Xmaster6y merged commit 5ad1107 into main Feb 13, 2026
7 checks passed
@Xmaster6y Xmaster6y deleted the local-knn branch February 13, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments