Constructor Summary
Public Constructor | ||
public |
constructor(optionsUser: Object) Constructor. |
Member Summary
Public Members | ||
public |
C: * |
|
public |
alphas: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
kernel: * |
|
public |
kernelCache: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
training: {"X": *, "y": *} |
|
public |
|
Method Summary
Public Methods | ||
public |
Apply the kernel to two data points. |
|
public |
calculateAlphaBounds(i: number, j: number): Array<number> Calculate the bounds on \alpha_j to make sure it can be clipped to the [0,C] box and that it can be chosen to satisfy the linear equality constraint stemming from the fact that the sum of all products y_i * a_i should equal 0. |
|
public |
getClassIndexSign(classIndex: number): number Get the signed value of the class index. |
|
public |
getSignClassIndex(sign: number): number Get the class index corresponding to a sign. |
|
public |
Retrieve the indices of the support vector samples. |
|
public |
Make a prediction for a data set. |
|
public |
sampleMargin(sample: Array<number> | number): number Calculate the margin (distance to the decision boundary) for a single sample. |
|
public |
train(X: *, y: *) |
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 Constructors
public constructor(optionsUser: Object) source
Constructor. Initialize class members and store user-defined options.
Params:
Name | Type | Attribute | Description |
optionsUser | Object |
|
User-defined options for SVM |
optionsUser.C | number |
|
Regularization (i.e. penalty for slack variables) |
optionsUser.kernel | Object |
|
Kernel. Defaults to the linear kernel |
optionsUser.convergenceNumPasses | number |
|
Number of passes without alphas changing to treat the algorithm as converged |
optionsUser.numericalTolerance | number |
|
Numerical tolerance for a value in the to be equal to another SMO algorithm to be equal to another value |
optionsUser.useKernelCache | boolean |
|
Whether to cache calculated kernel values for training sample pairs. Enabling this option (which is the default) generally improves the performance in terms of speed at the cost of memory |
Public Members
public C: * source
public alphas: * source
public convergenceNumPasses: * source
public kernel: * source
public kernelCache: * source
public kernelCacheStatus: * source
public numericalTolerance: * source
public supportVectors: * source
public training: {"X": *, "y": *} source
public useKernelCache: * source
Public Methods
public applyKernel(x: Array<number> | number, y: Array<number> | number): number source
Apply the kernel to two data points. Accepts both feature arrays and training data point indices for x and y. If x and y are integers, attempts to fetch the kernel result for the corresponding training data points from cache, and computes and stores the result in cache if it isn't found
Params:
Name | Type | Attribute | Description |
x | Array<number> | number | Feature vector or data point index for first data point. Arrays are treated as feature vectors, integers as training data point indices |
|
y | Array<number> | number | Feature vector or data point index for second data point. Arrays are treated as feature vectors, integers as training data point indices |
public calculateAlphaBounds(i: number, j: number): Array<number> source
Calculate the bounds on \alpha_j to make sure it can be clipped to the [0,C] box and that it can be chosen to satisfy the linear equality constraint stemming from the fact that the sum of all products y_i * a_i should equal 0.
public getClassIndexSign(classIndex: number): number source
Get the signed value of the class index. Returns -1 for class index 0, 1 for class index 1.
Params:
Name | Type | Attribute | Description |
classIndex | number | Class index |
public getSignClassIndex(sign: number): number source
Get the class index corresponding to a sign.
Params:
Name | Type | Attribute | Description |
sign | number | Sign |
public getSupportVectors(): Array<number> source
Retrieve the indices of the support vector samples.
public predict(features: Array<Array<mixed>>, optionsUser: Object): Array<mixed> source
Make a prediction for a data set.
Override:
Estimator#predictParams:
Name | Type | Attribute | Description |
features | Array<Array<mixed>> | Features for each data point. Each array element should be an array containing the features of the data point |
|
optionsUser | Object |
|
Options for prediction |
optionsUser.output | string |
|
Output for predictions. Either "classLabels" (default, output predicted class label), "raw" or "normalized" (both output margin (distance to decision boundary) for each sample) |
public sampleMargin(sample: Array<number> | number): number source
Calculate the margin (distance to the decision boundary) for a single sample.
public train(X: *, y: *) source
Train the supervised learning algorithm on a dataset.
Override:
Estimator#trainParams:
Name | Type | Attribute | Description |
X | * | ||
y | * |