preprocessing.LabelEncoder
Usage
import { LabelEncoder } from 'machinelearn/preprocessing';
const labelEncoder = new LabelEncoder();
const labelX = ['amsterdam', 'paris', 'tokyo'];
labelEncoder.fit(labelX);
const transformX = ['tokyo', 'tokyo', 'paris'];
const result = labelEncoder.transform(transformX);
// [ 2, 2, 1 ]
Constructors
Methods
Constructors
constructor
⊕ LabelEncoder()
Defined in
Parameters:
Param | Type | Default | Description |
---|
Returns: LabelEncoder
Methods
λ fit
Fit label encoder
Defined in preprocessing/label.ts:25
Parameters:
Param | Type | Default | Description |
---|---|---|---|
X | string[] or number[] or boolean[] | null | Input data in array or matrix |
Returns:
void
λ transform
Transform labels to normalized encoding.
Given classes of ['amsterdam', 'paris', 'tokyo']
It transforms ["tokyo", "tokyo", "paris"]
Into [2, 2, 1]
Defined in preprocessing/label.ts:40
Parameters:
Param | Type | Default | Description |
---|---|---|---|
X | string[] or number[] or boolean[] | null | Input data to transform according to the fitted state |
Returns:
any[]