paddlets.transform.onehot

class OneHot(cols: ~typing.Union[str, ~typing.List], dtype: object = <class 'numpy.float64'>, handle_unknown: str = 'error', categories: ~typing.Union[str, ~typing.List] = 'auto', drop: bool = False)[源代码]

基类:BaseTransform

使用one-hot编码转换dataset

参数
  • cols (str|List) – Column(s) to be encoded.

  • handle_unknown (str) – 可选值为{‘error’, ‘ignore’}, 默认为error

  • drop (bool) – 是否要删除原来列, 默认为不删除

  • dtype (object) – 数据类型,默认为float

  • categorie (str|List) – categories=’auto’时,编码时特征的取值取决于你输入编码数据的特征取值,两者的取值范围是一致的,categories取值为list时,编码时特征的取值为你输入的list(eg:list_features)的取值

返回

None

fit(dataset: TSDataset)[源代码]

Fit the ecnoder with the dataset.

参数

dataset (TSDataset) – dataset from which to fit the encoder

返回

self

transform(dataset: TSDataset, inplace: bool = False) TSDataset[源代码]

使用one-hot编码转换dataset

参数
  • dataset (TSDataset) – dataset to be transformed.

  • inplace (bool) – 是否对原dataset改变,默认为原dataset不变

返回

TSDataset

fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[源代码]

先对dataset进行拟合,再进行转换

参数
  • dataset (TSDataset) – dataset to be processed.

  • inplace (bool) – 是否对原dataset改变,默认为原dataset不变

返回

TSDataset