using_output_type#
- class cuml.using_output_type(output_type)[source]#
Configure the output type within a context.
- Parameters:
- output_type{‘input’, ‘cupy’, ‘numpy’, ‘cudf’, ‘pandas’, None}
Desired output type of results and attributes of the estimators.
None: No globally configured output type. This is the same as'input', except in cases where an estimator explicitly sets anoutput_type.'input': returns arrays of the same type as the inputs to the function or method. Fitted attributes will be of the same array type asX.'cupy': returnscupyarrays.'numpy': returnsnumpyarrays.'cudf': returnscudf.Seriesfor single dimensional results andcudf.DataFrameotherwise.'pandas': returnspandas.Seriesfor single dimensional results andpandas.DataFrameotherwise.
See also
Examples
>>> import cuml >>> import cupy as cp >>> import cudf
Fit a model with a cupy array. By default the fitted attributes will be cupy arrays.
>>> X = cp.array([[1.0, 4.0, 4.0], [2.0, 2.0, 2.0], [5.0, 1.0, 1.0]]) >>> model = cuml.DBSCAN(eps=1.0, min_samples=1).fit(X) >>> isinstance(model.labels_, cp.ndarray) True
With a global output type set though, the fitted attributes will match the configured output type.
>>> with cuml.using_output_type("cudf"): ... print(isinstance(model.labels_, cudf.Series)) True