Class: LabelEncoder

Encode target labels with value between 0 and n_classes-1.

This transformer should be used to encode target values, i.e. y, and not the input X.

Read more in the User Guide.

Python Reference

Constructors

new LabelEncoder()

new LabelEncoder(opts?): LabelEncoder

Parameters

ParameterTypeDescription
opts?object-
opts.classes_?ArrayLikeHolds the label for each class.

Returns LabelEncoder

Defined in generated/preprocessing/LabelEncoder.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/preprocessing/LabelEncoder.ts:23
_isInitializedbooleanfalsegenerated/preprocessing/LabelEncoder.ts:22
_pyPythonBridgeundefinedgenerated/preprocessing/LabelEncoder.ts:21
idstringundefinedgenerated/preprocessing/LabelEncoder.ts:18
optsanyundefinedgenerated/preprocessing/LabelEncoder.ts:19

Accessors

py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/preprocessing/LabelEncoder.ts:35

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/preprocessing/LabelEncoder.ts:87


fit()

fit(opts): Promise<any>

Fit label encoder.

Parameters

ParameterTypeDescription
optsobject-
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/preprocessing/LabelEncoder.ts:104


fit_transform()

fit_transform(opts): Promise<ArrayLike>

Fit label encoder and return encoded labels.

Parameters

ParameterTypeDescription
optsobject-
opts.y?ArrayLikeTarget values.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/LabelEncoder.ts:136


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/preprocessing/LabelEncoder.ts:170


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/preprocessing/LabelEncoder.ts:48


inverse_transform()

inverse_transform(opts): Promise<ArrayLike>

Transform labels back to original encoding.

Parameters

ParameterTypeDescription
optsobject-
opts.y?ArrayLikeTarget values.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/LabelEncoder.ts:204


set_output()

set_output(opts): Promise<any>

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/preprocessing/LabelEncoder.ts:240


transform()

transform(opts): Promise<ArrayLike>

Transform labels to normalized encoding.

Parameters

ParameterTypeDescription
optsobject-
opts.y?ArrayLikeTarget values.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/LabelEncoder.ts:272