Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,24 @@ Metrics (regression, classification, and distance)

Metrics (clustering and manifold learning)
------------------------------------------
.. automodule:: cuml.metrics.trustworthiness
:members:

.. automodule:: cuml.metrics.cluster.adjusted_rand_index
:members:
.. autofunction:: cuml.metrics.trustworthiness

.. automodule:: cuml.metrics.cluster.entropy
:members:
.. autofunction:: cuml.metrics.cluster.adjusted_rand_score

.. automodule:: cuml.metrics.cluster.homogeneity_score
:members:
.. autofunction:: cuml.metrics.cluster.entropy

.. automodule:: cuml.metrics.cluster.silhouette_score
:members:
.. autofunction:: cuml.metrics.cluster.homogeneity_score

.. automodule:: cuml.metrics.cluster.completeness_score
:members:
.. autofunction:: cuml.metrics.cluster.silhouette_score

.. automodule:: cuml.metrics.cluster.mutual_info_score
:members:
.. autofunction:: cuml.metrics.cluster.silhouette_samples

.. automodule:: cuml.metrics.cluster.v_measure_score
:members:
.. autofunction:: cuml.metrics.cluster.completeness_score

.. autofunction:: cuml.metrics.cluster.mutual_info_score

.. autofunction:: cuml.metrics.cluster.v_measure_score

Benchmarking
------------
Expand Down
13 changes: 12 additions & 1 deletion python/cuml/cuml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
del libcuml

import cupy
from pylibraft.common import Handle
from rmm.allocators.cupy import rmm_cupy_allocator

import cuml.feature_extraction
Expand Down Expand Up @@ -87,6 +86,18 @@ def __getattr__(name):
except AttributeError:
_global_settings_data.settings = GlobalSettings()
return _global_settings_data.settings
elif name == "Handle":
import warnings

from pylibraft.common import Handle

warnings.warn(
"cuml.Handle was deprecated in 26.02 and will be removed in 26.04. "
"There is no need to manually specify a `handle`, cuml now manages "
"this resource for you automatically.",
FutureWarning,
)
return Handle

raise AttributeError(f"module {__name__} has no attribute {name}")

Expand Down
21 changes: 11 additions & 10 deletions python/cuml/cuml/cluster/agglomerative.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from cuml.common import input_to_cuml_array
from cuml.common.array_descriptor import CumlArrayDescriptor
from cuml.common.doc_utils import generate_docstring
from cuml.internals.array import CumlArray
from cuml.internals.base import Base
from cuml.internals.base import Base, get_handle
from cuml.internals.mixins import ClusterMixin, CMajorInputTagMixin
from cuml.internals.outputs import reflect

Expand Down Expand Up @@ -80,13 +80,13 @@ class AgglomerativeClustering(Base, ClusterMixin, CMajorInputTagMixin):
Indirectly influences the number of neighbors to use when
``connectivity="knn"``, with ``n_neighbors = log(n_samples) + c``. The
default of 15 should suffice for most problems.
handle : cuml.Handle
Specifies the cuml.handle that holds internal CUDA state for
computations in this model. Most importantly, this specifies the CUDA
stream that will be used for the model's computations, so users can
run different models concurrently in different streams by creating
handles in several streams.
If it is None, a new one is created.
handle : cuml.Handle or None, default=None

.. deprecated:: 26.02
The `handle` argument was deprecated in 26.02 and will be removed
in 26.04. There's no need to pass in a handle, cuml now manages
this resource automatically.

verbose : int or boolean, default=False
Sets logging level. It must be one of `cuml.common.logger.level_*`.
See :ref:`verbosity-levels` for more info.
Expand Down Expand Up @@ -194,7 +194,8 @@ class AgglomerativeClustering(Base, ClusterMixin, CMajorInputTagMixin):
labels = CumlArray.empty(n_rows, dtype="int32", order="C")
children = CumlArray.empty((n_rows - 1, 2), dtype="int32", order="C")

cdef handle_t* handle_ = <handle_t*><size_t>self.handle.getHandle()
handle = get_handle(model=self)
cdef handle_t* handle_ = <handle_t*><size_t>handle.getHandle()
cdef int c = self.c
cdef float* X_ptr = <float*><uintptr_t>X.ptr
cdef int* children_ptr = <int*><uintptr_t>children.ptr
Expand All @@ -214,7 +215,7 @@ class AgglomerativeClustering(Base, ClusterMixin, CMajorInputTagMixin):
use_knn,
c,
)
self.handle.sync()
handle.sync()

# We only support single linkage for now, for other linkage types
# n_connected_components_ and n_leaves_ will differ
Expand Down
22 changes: 11 additions & 11 deletions python/cuml/cuml/cluster/dbscan.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
#

import cupy as cp
import numpy as np

from cuml.common.array_descriptor import CumlArrayDescriptor
from cuml.common.doc_utils import generate_docstring
from cuml.internals import logger, reflect
from cuml.internals.array import CumlArray
from cuml.internals.base import Base
from cuml.internals.base import Base, get_handle
from cuml.internals.input_utils import input_to_cuml_array
from cuml.internals.interop import (
InteropMixin,
Expand Down Expand Up @@ -152,13 +151,13 @@ class DBSCAN(Base,
eps : float (default = 0.5)
The maximum distance between 2 points such they reside in the same
neighborhood.
handle : cuml.Handle
Specifies the cuml.handle that holds internal CUDA state for
computations in this model. Most importantly, this specifies the CUDA
stream that will be used for the model's computations, so users can
run different models concurrently in different streams by creating
handles in several streams.
If it is None, a new one is created.
handle : cuml.Handle or None, default=None

.. deprecated:: 26.02
The `handle` argument was deprecated in 26.02 and will be removed
in 26.04. There's no need to pass in a handle, cuml now manages
this resource automatically.

min_samples : int (default = 5)
The number of samples in a neighborhood such that this group can be
considered as an important core point (including the point itself).
Expand Down Expand Up @@ -399,7 +398,8 @@ class DBSCAN(Base,
cdef uintptr_t core_sample_indices_ptr = (
0 if core_sample_indices is None else core_sample_indices.ptr
)
cdef handle_t* handle_ = <handle_t*><size_t>self.handle.getHandle()
handle = get_handle(model=self)
cdef handle_t* handle_ = <handle_t*><size_t>handle.getHandle()
cdef bool X_f32 = X.dtype == np.float32
cdef bool labels_i32 = labels.dtype == np.int32

Expand Down Expand Up @@ -467,7 +467,7 @@ class DBSCAN(Base,
algorithm,
verbose,
multi_gpu)
self.handle.sync()
handle.sync()

if core_sample_indices is not None:
# Trim the core_sample_indices array if necessary. In the common case
Expand Down
Loading