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)[source]

Bases: BaseTransform

Transform categorical columns with OneHot encoder.

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

  • handle_unknown (str) – {‘error’, ‘ignore’}, default=’error’

  • drop (bool) – Whether to delete the original column, default=False

  • dtype (object) – Data type, default=float

  • categorie (str|List) – ‘auto’ or a list of array-like, default=’auto’, if categorie is ‘auto’, it determine categories automatically from the dataset.

Returns

None

fit(dataset: TSDataset)[source]

Fit the ecnoder with the dataset.

Parameters

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

Returns

self

transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]

Transform the dataset with the fitted encoder.

Parameters
  • dataset (TSDataset) – dataset to be transformed.

  • inplace (bool) – whether to replace the original data. default=False

Returns

TSDataset

fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]

First fit the encoder, and then transform the dataset.

Parameters
  • dataset (TSDataset) – dataset to be processed.

  • inplace (bool) – whether to replace the original data. default=False

Returns

TSDataset