Skip to content

Commit b0cae30

Browse files
committed
Support radius_neighbors_graph in cuml.accel
1 parent c8dbb2e commit b0cae30

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

python/cuml/cuml/accel/_wrappers/sklearn/neighbors.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#
2-
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

66
import cuml.neighbors
77
from cuml.accel.estimator_proxy import ProxyBase
8+
from cuml.common.sparse_utils import is_sparse
9+
from cuml.internals.interop import UnsupportedOnGPU
810

911
__all__ = (
1012
"NearestNeighbors",
@@ -18,6 +20,21 @@ class NearestNeighbors(ProxyBase):
1820
_gpu_class = cuml.neighbors.NearestNeighbors
1921
_other_attributes = frozenset(("_fit_method", "_tree", "_fit_X"))
2022

23+
def _gpu_radius_neighbors_graph(
24+
self, X=None, radius=None, mode="connectivity", sort_results=False
25+
):
26+
if mode != "connectivity":
27+
raise UnsupportedOnGPU(f"`mode={mode!r}` is not supported")
28+
if sort_results:
29+
raise UnsupportedOnGPU("`sort_results=True` is not supported")
30+
if is_sparse(X):
31+
raise UnsupportedOnGPU("Sparse inputs are not supported")
32+
if self.effective_metric_ not in cuml.neighbors.VALID_METRICS["rbc"]:
33+
raise UnsupportedOnGPU(
34+
f"metric={self.effective_metric_!r} is not supported"
35+
)
36+
return self._gpu.radius_neighbors_graph(X=X, radius=radius)
37+
2138

2239
class KNeighborsClassifier(ProxyBase):
2340
_gpu_class = cuml.neighbors.KNeighborsClassifier

0 commit comments

Comments
 (0)