paddlets.transform.ordinal

class Ordinal(cols: Union[str, List], dtype: dtype = dtype('float64'), categories: Union[str, List] = 'auto', unknown_value: Union[None, int] = None, handle_unknown: str = 'error', drop: bool = False)[source]

Bases: BaseTransform

Encode categorical features as an integer array.

Parameters
  • cols (str|List) – Name of columns to Encode

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

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

  • dtype (object) – Number type, default=float.

  • unknown_value (str) – int or np.nan, default=None.

  • categorie (str|List) – ‘auto’ or a list of array-like, default=’auto’,if categorie is ‘auto’, it determine categories automatically from the training data. if categorie is list, categories[i] holds the categories expected in the ith column. The passed categories should not mix strings and numeric values, and should be sorted in case of numeric values.

Returns

None

fit(dataset: TSDataset)[source]

Fit the OrdinalEncoder to dataset.

Parameters

dataset (TSDataset) – Dataset to be fitted.

Returns

Ordinal

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

Transform dataset to ordinal codes

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

  • inplace (bool) – Whether to perform the transformation inplace. default=False

Returns

TSDataset

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

Fit OrdinalEncoder to dataset, then transform dataset.

Parameters
  • dataset (TSDataset) – Dataset to be fitted and transformed.

  • inplace (bool) – Whether to perform the transformation inplace.default=False

Returns

TSDataset