OneVsAllClassifier
Extends:
Direct Subclass:
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 |
classifiers: * |
Method Summary
Public Methods | ||
public abstract |
createClassifier(classIndex: number): BinaryClassifier Create a binary classifier for one of the classes. |
|
public |
createClassifiers(y: Array<number>) Create all binary classifiers. |
|
public |
getClasses(): Array<number> 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 |
Make a prediction for a data set. |
|
public abstract |
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:
Name | Type | Attribute | Description |
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.
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.
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#predictParams:
Name | Type | Attribute | Description |
X | * |
Return:
* |
public predictProba(X: Array.Array<number>): Array.Array<number> source
Make a probabilistic prediction for a data set.
Params:
Name | Type | Attribute | Description |
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
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