Skip to content

Instantly share code, notes, and snippets.

@dantegd
Created April 28, 2020 14:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dantegd/7330b63446d2584be5993143bac341aa to your computer and use it in GitHub Desktop.
Usage of cuML's context manager `using_output_type`
import cuml
import cupy as cp
ary = [[1.0, 4.0, 4.0], [2.0, 2.0, 2.0], [5.0, 1.0, 1.0]]
ary = cp.asarray(ary)
with cuml.using_output_type('cudf'):
dbscan = cuml.DBSCAN(eps=1.0, min_samples=1)
dbscan.fit(ary)
print(type(dbscan_float.labels_))
# <class 'cudf.core.Series'>
kmeans = cuml.KMeans(n_clusters=2)
kmeans.fit(ary)
print(type(kmeans.labels_))
# <class 'cupy.core.core.ndarray'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment