用法:
cuml.common.memory_utils.using_output_type(output_type)
在
with
語句中設置 cuML 的全局輸出類型的上下文管理器方法。一旦with
代碼塊被執行,它就會重置為之前的值。- output_type:{‘input’, ‘cudf’, ‘cupy’, ‘numpy’}(默認 = ‘input’)
期望的結果輸出類型和估計器的屬性。
'input'
意味著參數和方法將盡可能地鏡像發送到估計器/方法的數據格式。具體來說:輸入類型
輸出類型
cuDF DataFrame 或係列
cuDF DataFrame 或係列
NumPy 數組
NumPy 數組
Pandas DataFrame 或係列
NumPy 數組
Numba 設備陣列
Numba 設備陣列
CuPy 數組
CuPy 數組
其他
__cuda_array_interface__
對象CuPy 數組
'cudf'
將為單維結果返回 cuDF 係列,為其餘結果返回 DataFrames。'cupy'
將返回 CuPy 數組。'numpy'
將返回 NumPy 數組。
參數:
例子:
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_float = cuml.DBSCAN(eps=1.0, min_samples=1) dbscan_float.fit(ary) print("cuML output inside 'with' context") print(dbscan_float.labels_) print(type(dbscan_float.labels_)) # use cuml again outside the context manager dbscan_float2 = cuml.DBSCAN(eps=1.0, min_samples=1) dbscan_float2.fit(ary) print("cuML default output") print(dbscan_float2.labels_) print(type(dbscan_float2.labels_))
輸出:
cuML output inside 'with' context 0 0 1 1 2 2 dtype: int32 <class 'cudf.core.series.Series'> cuML default output [0 1 2] <class 'cupy.ndarray'>
相關用法
- Python cuml.common.memory_utils.set_global_output_type用法及代碼示例
- Python cuml.metrics.pairwise_distances.pairwise_distances用法及代碼示例
- Python cuml.neighbors.KNeighborsClassifier用法及代碼示例
- Python cuml.ensemble.RandomForestRegressor用法及代碼示例
- Python cuml.svm.SVC用法及代碼示例
- Python cuml.svm.SVR用法及代碼示例
- Python cuml.Lasso用法及代碼示例
- Python cuml.tsa.ARIMA.predict用法及代碼示例
- Python cuml.multiclass.OneVsRestClassifier用法及代碼示例
- Python cuml.preprocessing.LabelBinarizer用法及代碼示例
- Python cuml.random_projection.GaussianRandomProjection用法及代碼示例
- Python cuml.MBSGDRegressor用法及代碼示例
- Python cuml.experimental.preprocessing.PolynomialFeatures用法及代碼示例
- Python cuml.PCA用法及代碼示例
- Python cuml.feature_extraction.text.HashingVectorizer用法及代碼示例
- Python cuml.DBSCAN用法及代碼示例
- Python cuml.dask.feature_extraction.text.TfidfTransformer用法及代碼示例
- Python cuml.TruncatedSVD用法及代碼示例
- Python cuml.preprocessing.text.stem.PorterStemmer用法及代碼示例
- Python cuml.experimental.preprocessing.add_dummy_feature用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cuml.common.memory_utils.using_output_type。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。