snowflake.ml.modeling.preprocessing.LabelEncoder

class snowflake.ml.modeling.preprocessing.LabelEncoder(input_cols: Optional[Union[str, Iterable[str]]] = None, output_cols: Optional[Union[str, Iterable[str]]] = None, passthrough_cols: Optional[Union[str, Iterable[str]]] = None, drop_input_cols: Optional[bool] = False)

Bases: BaseTransformer

Encodes target labels with values between 0 and n_classes-1.

In other words, each class (i.e., distinct numeric or string) is assigned an integer value, starting with zero. LabelEncoder is a specialization of OrdinalEncoder for 1-dimensional data.

For more details on what this transformer does, see sklearn.preprocessing.LabelEncoder.

Args:
input_cols: Optional[Union[str, List[str]]]

The name of a column in a DataFrame to be encoded. May be a string or a list containing one string.

output_cols: Optional[Union[str, List[str]]]

The name of a column in a DataFrame where the results will be stored. May be a string or a list containing one string.

passthrough_cols: Optional[Union[str, List[str]]]

A string or a list of strings indicating column names to be excluded from any operations (such as train, transform, or inference). These specified column(s) will remain untouched throughout the process. This option is helpful in scenarios requiring automatic input_cols inference, but need to avoid using specific columns, like index columns, during training or inference.

drop_input_cols: Optional[bool], default=False

Remove input columns from output if set True. False by default.

Methods

fit(dataset)

Fit label encoder with label column in dataset.

get_input_cols()

Input columns getter.

get_label_cols()

Label column getter.

get_output_cols()

Output columns getter.

get_params([deep])

Get parameters for this transformer.

get_passthrough_cols()

Passthrough columns getter.

get_sample_weight_col()

Sample weight column getter.

get_sklearn_args([default_sklearn_obj, ...])

Get sklearn keyword arguments.

set_drop_input_cols([drop_input_cols])

set_input_cols(input_cols)

Input columns setter.

set_label_cols(label_cols)

Label column setter.

set_output_cols(output_cols)

Output columns setter.

set_params(**params)

Set the parameters of this transformer.

set_passthrough_cols(passthrough_cols)

Passthrough columns setter.

set_sample_weight_col(sample_weight_col)

Sample weight column setter.

to_lightgbm()

to_sklearn()

to_xgboost()

transform(dataset)

Use fit result to transform snowpark dataframe or pandas dataframe.