Class: Codec

Codec(argmap)

The constructor and methods of codecs.

Create a codec:

let setosa = {
    petal_length: "1.5",
    species: "setosa"
};

let versicolor = {
    petal_length: "3.8",
    species: "versicolor"
};

let dataset = [setosa, versicolor];

let attributes = [
  ["petal_length", false],
  ["species", true],
];

let codec = new Codec({attributes: attributes, data: dataset});

Encode a data point:

codec.encode(setosa);

Decode a data point:

codec.decode([0.0, 1.0, 0.0]);

Get the JSON representation of the codec:

codec.json();

Constructor

new Codec(argmap)

Creates a codec by consuming an iterable of data points.

Parameters:
Name Type Description
argmap

An object that contains the properties attributes (the array of attributes that defines their names and types: discrete or not) and data (the iterable that contains the data points). Alternatively, the argmap can be an object with a single parameter json (the JSON representation of a codec).

Source:

Methods

decode(encodedValues)

Decodes a data point.

Parameters:
Name Type Description
encodedValues

An encoded data point as an array of numbers between 0.0 and 1.0.

Source:
Returns:

The decoded data point as an object of string properties.

encode(datapoint)

Encodes a data point.

Parameters:
Name Type Description
datapoint

A data point as an object of string properties.

Source:
Returns:

The encoded data point as an array of numbers between 0.0 and 1.0.

json()

The JSON representation of the codec.

Source:
Returns:

The JSON representation of the codec.