Skip to content

Conversation

@jcrist
Copy link
Member

@jcrist jcrist commented Oct 27, 2025

This PR is a general cleanup of KernelDensity, as well as exposing it through cuml.accel.

Summary:

  • Fixes the output handling of KernelDensity.sample to properly reflect the input type.
  • Adds support for bandwidth="scott" and bandwidth="silverman", mirroring the sklearn api.
  • Improves sklearn API compatibility
  • Improves input and parameter validation
  • Includes additional code cleanups for readability and consistency
  • Adds as_sklearn/from_sklearn support to KernelDensity
  • Adds support for KernelDensity in cuml.accel

Fixes #7214.
Part of #7317.

We only need to raise `NotImplementedError` for invalid kernels, we
don't need to also ensure `metric == "euclidean"`. Our implementation
matches that of sklearn, and they only check the kernel not the metric.
@jcrist jcrist self-assigned this Oct 27, 2025
@jcrist jcrist requested a review from a team as a code owner October 27, 2025 19:41
@jcrist jcrist requested a review from csadorf October 27, 2025 19:41
@jcrist jcrist added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change cuml-accel Issues related to cuml.accel algo: neighbors labels Oct 27, 2025
@github-actions github-actions bot added the Cython / Python Cython or Python issue label Oct 27, 2025
Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

Found one bug, but otherwise LGTM.

Approving pending the tiny fix.

@jcrist
Copy link
Member Author

jcrist commented Oct 28, 2025

/merge

@rapids-bot rapids-bot bot merged commit 178b5ca into rapidsai:main Oct 28, 2025
100 of 101 checks passed
@jcrist jcrist deleted the cleanup-kernel-density branch October 28, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

algo: neighbors cuml-accel Issues related to cuml.accel Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add KernelDensity support to cuml.accel

2 participants