Home Reference Source
import Dataset from '@jsmlt/jsmlt/src/data/dataset.js'
public class | source

Dataset

Container of data points for a single data set.

Constructor Summary

Public Constructor
public

Initialize object properties.

Member Summary

Public Members
public

datapoints: *[]

public
public

Method Summary

Public Methods
public

addDatapoint(features: *): *

Add a data point to the data set.

public

Get all data points from this dataset

public

Extract the features from the datapoints and return them in an n x d array, where n is the number of data points and d is the number of dimensions (number of features per datapoint).

public

Extract the labels from the datapoints and return them in an array.

public

Get the number of dimensions for the features of data points

public

isValidDataPoint(datapoint: *): *

Check whether a data point is valid.

public

Get the number of data points in this dataset

Public Constructors

public constructor() source

Initialize object properties.

Public Members

public datapoints: *[] source

public numDatapoints: number source

public numDimensions: number source

Public Methods

public addDatapoint(features: *): * source

Add a data point to the data set. Data point should be an array with the number of dimensions used throughout the dataset.

Params:

NameTypeAttributeDescription
features *

Data point features array

Return:

*

public getDataPoints(): * source

Get all data points from this dataset

Return:

*

Array Data points. Array of datapoint objects

public getFeaturesArray(): * source

Extract the features from the datapoints and return them in an n x d array, where n is the number of data points and d is the number of dimensions (number of features per datapoint).

Return:

*

Array[Array[Number]] Features matrix

public getLabelsArray(): * source

Extract the labels from the datapoints and return them in an array.

Return:

*

Array[mixed] Labels array

public getNumDimensions(): * source

Get the number of dimensions for the features of data points

Return:

*

int Dimensionality

public isValidDataPoint(datapoint: *): * source

Check whether a data point is valid. A valid data point is an array of the correct number of dimensions.

Params:

NameTypeAttributeDescription
datapoint *

Data point to be checked

Return:

*

bool Whether the data point is valid

public numDataPoints(): * source

Get the number of data points in this dataset

Return:

*

int Number of data points