用法:
class dask_ml.preprocessing.DummyEncoder(columns: Optional[Sequence[Any]] = None, drop_first: bool = False)
虛擬 (one-hot) 對分類列進行編碼。
- columns:順序,可選
虛擬編碼的列。必須是分類數據類型。默認情況下,Dummy 對所有分類 dtype 列進行編碼。
- drop_first:布爾值,默認為 False
是否刪除每列中的第一個類別。
- columns_: index
虛擬編碼前訓練數據中的列
- transformed_columns_: index
虛擬編碼後訓練數據中的列
- categorical_columns_: index
訓練數據中的分類列
- noncategorical_columns_: index
訓練數據中的其餘列
- categorical_blocks_:dict
從列名映射到切片對象。切片表示分類列最終在轉換後的數組中的位置
- dtypes_:dict
字典映射列名到
- CategoricalDtype 的實例(pandas >= 0.21.0)
- (類別,有序)的元組
參數:
屬性:
注意:
此轉換器僅適用於 dask 和 pandas 數據幀。對於 dask DataFrames,您的所有分類都應該是已知的。
逆變換可用於數據幀或數組。
例子:
>>> data = pd.DataFrame({"A": [1, 2, 3, 4], ... "B": pd.Categorical(['a', 'a', 'a', 'b'])}) >>> de = DummyEncoder() >>> trn = de.fit_transform(data) >>> trn A B_a B_b 0 1 1 0 1 2 1 0 2 3 1 0 3 4 0 1
>>> de.columns_ Index(['A', 'B'], dtype='object')
>>> de.non_categorical_columns_ Index(['A'], dtype='object')
>>> de.categorical_columns_ Index(['B'], dtype='object')
>>> de.dtypes_ {'B': CategoricalDtype(categories=['a', 'b'], ordered=False)}
>>> de.categorical_blocks_ {'B': slice(1, 3, None)}
>>> de.fit_transform(dd.from_pandas(data, 2)) Dask DataFrame Structure: A B_a B_b npartitions=2 0 int64 uint8 uint8 2 ... ... ... 3 ... ... ... Dask Name: get_dummies, 4 tasks
相關用法
- Python dask_ml.preprocessing.MinMaxScaler用法及代碼示例
- Python dask_ml.preprocessing.Categorizer用法及代碼示例
- Python dask_ml.preprocessing.OrdinalEncoder用法及代碼示例
- Python dask_ml.preprocessing.LabelEncoder用法及代碼示例
- Python dask_ml.preprocessing.PolynomialFeatures用法及代碼示例
- Python dask_ml.preprocessing.StandardScaler用法及代碼示例
- Python dask_ml.preprocessing.QuantileTransformer用法及代碼示例
- Python dask_ml.preprocessing.RobustScaler用法及代碼示例
- Python dask_ml.preprocessing.BlockTransformer用法及代碼示例
- Python dask_ml.wrappers.ParallelPostFit用法及代碼示例
- Python dask_ml.feature_extraction.text.CountVectorizer用法及代碼示例
- Python dask_ml.linear_model.LinearRegression用法及代碼示例
- Python dask_ml.wrappers.Incremental用法及代碼示例
- Python dask_ml.metrics.mean_squared_log_error用法及代碼示例
- Python dask_ml.model_selection.GridSearchCV用法及代碼示例
- Python dask_ml.feature_extraction.text.FeatureHasher用法及代碼示例
- Python dask_ml.ensemble.BlockwiseVotingClassifier用法及代碼示例
- Python dask_ml.model_selection.train_test_split用法及代碼示例
- Python dask_ml.decomposition.PCA用法及代碼示例
- Python dask_ml.feature_extraction.text.HashingVectorizer用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 dask_ml.preprocessing.DummyEncoder。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。