API Reference - Models - KalmanFilter

KalmanFilter is a supervised machine learning model that predicts continuous values (e.g. 1.2, -32, 90, -1.2 and etc.). It uses iterative calculations to find the best model parameters.

Stored Model Parameters

Contains a matrix.

  • ModelParameters[I][J]: Value of matrix at row I and column J. The rows are the features.

Constructors

new()

Create new model object. If any of the arguments are nil, default argument values for that argument will be used.

KalmanFilter.new(stateTransitionModelMatrix: matrix, observationModelMatrix: matrix, processNoiseCovarianceMatrix: matrix, observationNoiseCovarianceMatrix: matrix, controlInputMatrix: matrix, controlVector: matrix, noiseValue: number, lossFunction: string, useJosephForm: boolean): ModelObject

Parameters:

  • stateTransitionModelMatrix: The state transition matrix that describes how the state evolves from one time step to the next without controls or noise. [Default: identity matrix]

  • observationModelMatrix: The observation matrix that maps the true state space into the observed space. [Default: identity matrix]

  • processNoiseCovarianceMatrix: The process noise covariance matrix representing the uncertainty in the state transition model. [Default: identity matrix]

  • observationNoiseCovarianceMatrix: The observation noise covariance matrix representing the uncertainty in the observation model. [Default: identity matrix]

  • controlInputMatrix: The control-input matrix that maps control vectors to state space. [Default: zero matrix]

  • controlVector: The control vector representing external inputs applied to the system. [Default: zero vector]

  • noiseValue: The noise value to be used by observationNoiseCovarianceMatrix and processNoiseCovarianceMatrix. [Default: 1]

  • lossFunction: The function to calculate the cost of each training. Available options are:

Function Input Range (From Predicted Label Vector And Label Vector) Output Range Characteristics Use Cases
L2 (Default) (-∞, ∞) (0, ∞) Quadratic penalty, sensitive to outliers Regression with normally distributed errors, when outliers are minimal
L1 (-∞, ∞) (0, ∞) Linear penalty, robust to outliers Robust regression, when dataset contains outliers, median prediction
Mahalanobis (-∞, ∞) (0, ∞) Accounts for correlations between variables, scale-invariant, uses covariance matrix Regression with correlated features, multivariate outlier detection, when feature dependencies matter
  • useJosephForm: Set whether or not to use a more numerically accurate representation in exchange for lower performance [Default: true]

Returns:

  • ModelObject: The generated model object.

Functions

train()

Train the model.

KalmanFilter:train(previousStateMatrix: matrix, labelVector: matrix): number[]

Parameters:

  • previousStateMatrix: A matrix containing all previous state data.

  • currentStateMatrix: A matrix containing all current state data.

Returns:

  • costArray: An array containing cost values.

predict()

Predict the value for a given data.

KalmanFilter:predict(previousStateMatrix: matrix): matrix

Parameters:

  • previousStateMatrix: A matrix containing all previous state data.

Returns:

  • predictedNextStateMatrix: A matrix containing all next state data that are predicted by the model.

Inherited From


This site uses Just the Docs, a documentation theme for Jekyll.