preprocessing.OneHotEncoder
Usage
const enc = new OneHotEncoder();
const planetList = [
{ planet: 'mars', isGasGiant: false, value: 10 },
{ planet: 'saturn', isGasGiant: true, value: 20 },
{ planet: 'jupiter', isGasGiant: true, value: 30 }
];
const encodeInfo = enc.encode(planetList, {
dataKeys: ['value', 'isGasGiant'],
labelKeys: ['planet']
});
// encodeInfo.data -> [ [ -1, 0, 1, 0, 0 ], [ 0, 1, 0, 1, 0 ], [ 1, 1, 0, 0, 1 ] ]
const decodedInfo = enc.decode(encodeInfo.data, encodeInfo.decoders);
// gives you back the original value, which is `planetList`
Constructors
Methods
Constructors
constructor
⊕ OneHotEncoder()
Defined in
Parameters:
Param | Type | Default | Description |
---|
Returns: OneHotEncoder
Methods
λ decode
Decode the encoded data back into its original format
Defined in preprocessing/data.ts:188
Parameters:
Param | Type | Default | Description |
---|---|---|---|
encoded | any | ||
decoders | any |
Returns:
any[]
λ encode
encode data according to dataKeys and labelKeys
Defined in preprocessing/data.ts:105
Parameters:
Param | Type | Default | Description |
---|---|---|---|
data | any | null | list of records to encode |
dataKeys | string[] | null | |
labelKeys | string[] | null |
Returns:
Param | Type | Description |
---|---|---|
data | any[] | Encoded data |
decoders | any[] | Decoder |