用法:
class cuml.dask.preprocessing.LabelBinarizer(*, client=None, **kwargs)
LabelBinarizer 的分布式版本,用於 one-hot 編碼標簽集合。
例子:
創建一個帶有標簽的數組並對它們進行虛擬編碼
import cupy as cp import cupyx from cuml.dask.preprocessing import LabelBinarizer from dask_cuda import LocalCUDACluster from dask.distributed import Client import dask cluster = LocalCUDACluster() client = Client(cluster) labels = cp.asarray([0, 5, 10, 7, 2, 4, 1, 0, 0, 4, 3, 2, 1], dtype=cp.int32) labels = dask.array.from_array(labels) lb = LabelBinarizer() encoded = lb.fit_transform(labels) print(str(encoded.compute()) decoded = lb.inverse_transform(encoded) print(str(decoded.compute())
輸出:
[[1 0 0 0 0 0 0 0] [0 0 0 0 0 1 0 0] [0 0 0 0 0 0 0 1] [0 0 0 0 0 0 1 0] [0 0 1 0 0 0 0 0] [0 0 0 0 1 0 0 0] [0 1 0 0 0 0 0 0] [1 0 0 0 0 0 0 0] [1 0 0 0 0 0 0 0] [0 0 0 0 1 0 0 0] [0 0 0 1 0 0 0 0] [0 0 1 0 0 0 0 0] [0 1 0 0 0 0 0 0]] [ 0 5 10 7 2 4 1 0 0 4 3 2 1]
相關用法
- Python cuml.dask.feature_extraction.text.TfidfTransformer用法及代碼示例
- Python cuml.dask.manifold.UMAP用法及代碼示例
- Python cuml.dask.datasets.classification.make_classification用法及代碼示例
- Python cuml.dask.decomposition.PCA用法及代碼示例
- Python cuml.dask.naive_bayes.MultinomialNB用法及代碼示例
- Python cuml.dask.decomposition.TruncatedSVD用法及代碼示例
- Python cuml.datasets.make_blobs用法及代碼示例
- Python cuml.datasets.make_classification用法及代碼示例
- Python cuml.datasets.make_arima用法及代碼示例
- Python cuml.datasets.make_regression用法及代碼示例
- 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用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cuml.dask.preprocessing.LabelBinarizer。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。