Home Reference Source
import {OneVsAllClassifier} from '@jsmlt/jsmlt/src/supervised/base.js'
public class | source

OneVsAllClassifier

Extends:

EstimatorClassifier → OneVsAllClassifier

Base class for multiclass classifiers using the one-vs-all classification method. For a training set with k unique class labels, the one-vs-all classifier creates k binary classifiers. Each of these classifiers is trained on the entire data set, where the i-th classifier treats all samples that do not come from the i-th class as being from the same class. In the prediction phase, the one-vs-all classifier runs all k binary classifiers on the test data point, and predicts the class that has the highest normalized prediction value

Member Summary

Public Members
public

Method Summary

Public Methods
public abstract

createClassifier(classIndex: number): BinaryClassifier

Create a binary classifier for one of the classes.

public

Create all binary classifiers.

public

Get the class labels corresponding with each internal class label.

public

Retrieve the individual binary one-vs-all classifiers.

public

predict(X: *): *

public

predictProba(X: Array.Array<number>): Array.Array<number>

Make a probabilistic prediction for a data set.

public

trainBatch(X: Array<Array<number>>, y: Array<mixed>)

Train all binary classifiers one-by-one

public

Train all binary classifiers iteration by iteration, i.e.

Inherited Summary

From class Estimator
public abstract

predict(X: Array<Array<number>>): Array<mixed>

Make a prediction for a data set.

public abstract

train(X: Array<Array<number>>, y: Array<mixed>)

Train the supervised learning algorithm on a dataset.

Public Members

public classifiers: * source

Public Methods

public abstract createClassifier(classIndex: number): BinaryClassifier source

Create a binary classifier for one of the classes.

Params:

NameTypeAttributeDescription
classIndex number

Class index of the positive class for the binary classifier

Return:

BinaryClassifier

Binary classifier

public createClassifiers(y: Array<number>) source

Create all binary classifiers. Creates one classifier per class.

Params:

NameTypeAttributeDescription
y Array<number>

Class labels for the training data

public getClasses(): Array<number> source

Get the class labels corresponding with each internal class label. Can be used to determine which predictino is for which class in predictProba.

Return:

Array<number>

The n-th element in this array contains the class label of what is internally class n

public getClassifiers(): Array<Classifier> source

Retrieve the individual binary one-vs-all classifiers.

Return:

Array<Classifier>

List of binary one-vs-all classifiers used as the base classifiers for this multiclass classifier

public predict(X: *): * source

Make a prediction for a data set.

Override:

Estimator#predict

Params:

NameTypeAttributeDescription
X *

Return:

*

See:

public predictProba(X: Array.Array<number>): Array.Array<number> source

Make a probabilistic prediction for a data set.

Params:

NameTypeAttributeDescription
X Array.Array<number>

Features for each data point

Return:

Array.Array<number>

Probability predictions. Each array element contains the probability of that particular class. The array elements are ordered in the order the classes appear in the training data (i.e., if class "A" occurs first in the labels list in the training, procedure, its probability is returned in the first array element of each sub-array)

public trainBatch(X: Array<Array<number>>, y: Array<mixed>) source

Train all binary classifiers one-by-one

Params:

NameTypeAttributeDescription
X Array<Array<number>>

Features per data point

y Array<mixed>

Class labels per data point

public trainIterative() source

Train all binary classifiers iteration by iteration, i.e. start with the first training iteration for each binary classifier, then execute the second training iteration for each binary classifier, and so forth. Can be used when one needs to keep track of information per iteration, e.g. accuracy