Home Reference Source
import {BinaryPerceptron} from '@jsmlt/jsmlt/src/supervised/linear/perceptron.js'
public class | source

BinaryPerceptron

Extends:

EstimatorClassifier → BinaryPerceptron

Perceptron learner for binary classification problem.

Member Summary

Public Members
public

weights: *

public

Method Summary

Public Methods
public

Check whether training has convergence when using iterative training using trainIteration.

public

Get the signed value of the class index.

public

Get the class index corresponding to a sign.

public

predict(features: Array.Array<number>, optionsUser: Object): Array<number>

Make a prediction for a data set.

public

train(X: *, y: *)

public

Train the classifier for a single iteration on the stored training data.

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 weights: * source

public weightsIncrement: * source

Public Methods

public checkConvergence(): boolean source

Check whether training has convergence when using iterative training using trainIteration.

Return:

boolean

Whether the algorithm has converged

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:

NameTypeAttributeDescription
classIndex number

Class index

Return:

number

Sign corresponding to class index

public getSignClassIndex(sign: number): number source

Get the class index corresponding to a sign.

Params:

NameTypeAttributeDescription
sign number

Sign

Return:

number

Class index corresponding to sign

public predict(features: Array.Array<number>, optionsUser: Object): Array<number> source

Make a prediction for a data set.

Override:

Estimator#predict

Params:

NameTypeAttributeDescription
features Array.Array<number>

Features for each data point

optionsUser Object
  • optional

User-defined options

optionsUser.output string
  • optional
  • default: 'classLabels'

Output for predictions. Either "classLabels" (default, output predicted class label), "raw" (dot product of weights vector with augmented features vector) or "normalized" (dot product from "raw" but with unit-length weights)

Return:

Array<number>

Predictions. Output dependent on options.output, defaults to class labels

public train(X: *, y: *) source

Train the supervised learning algorithm on a dataset.

Override:

Estimator#train

Params:

NameTypeAttributeDescription
X *
y *

See:

public trainIteration(X: Array<Array<number>>, y: Array<mixed>): undefined[] source

Train the classifier for a single iteration on the stored training data.

Params:

NameTypeAttributeDescription
X Array<Array<number>>

Features per data point

y Array<mixed>

Class labels per data point

Return:

undefined[]