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 (opens in a new tab)
Constructors
constructor()
Signature
new LabelEncoder(opts?: object): LabelEncoder;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.classes_? | ArrayLike | Holds the label for each class. |
Returns
Defined in: generated/preprocessing/LabelEncoder.ts:25 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/preprocessing/LabelEncoder.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/preprocessing/LabelEncoder.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/preprocessing/LabelEncoder.ts:21 (opens in a new tab)
id
string
Defined in: generated/preprocessing/LabelEncoder.ts:18 (opens in a new tab)
opts
any
Defined in: generated/preprocessing/LabelEncoder.ts:19 (opens in a new tab)
Accessors
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/preprocessing/LabelEncoder.ts:35 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/preprocessing/LabelEncoder.ts:39 (opens in a new tab)
Methods
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/preprocessing/LabelEncoder.ts:88 (opens in a new tab)
fit()
Fit label encoder.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/preprocessing/LabelEncoder.ts:105 (opens in a new tab)
fit_transform()
Fit label encoder and return encoded labels.
Signature
fit_transform(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<ArrayLike
>
Defined in: generated/preprocessing/LabelEncoder.ts:138 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/preprocessing/LabelEncoder.ts:48 (opens in a new tab)
inverse_transform()
Transform labels back to original encoding.
Signature
inverse_transform(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<ArrayLike
>
Defined in: generated/preprocessing/LabelEncoder.ts:171 (opens in a new tab)
set_output()
Set output container.
See Introducing the set_output API for an example on how to use the API.
Signature
set_output(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/preprocessing/LabelEncoder.ts:208 (opens in a new tab)
transform()
Transform labels to normalized encoding.
Signature
transform(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<ArrayLike
>
Defined in: generated/preprocessing/LabelEncoder.ts:241 (opens in a new tab)