ExpectationMaximization is an unsupervised machine learning model that predicts which cluster that the input belongs to using probability.
Code Sample
local featureMatrix = {
{123, -100},
{30, 40},
{12, 43},
{95, 90},
}
local meanMatrix, probabilityMatrix, cost = MachineLL.ExpectationMaximization:train(featureMatrix, nil, nil, nil, nil, false, false, false, false)
local clusterNumber, probabilityVector = MachineLL.ExpectationMaximization:predict(featureVector, meanMatrix, probabilitiesMatrix)
Functions
:train()
train(featureMatrix: matrix, numberOfClusters: integer, maxNumberOfIterations: integer, epsilon: number, suppressOutput: boolean): matrix, matrix, number
Arguments:
featureMatrix
: The matrix containing values for the model to train onnumberOfClusters
: Number of clusters for model to train and predict onmaxNumberOfIterations
: Maximum number of iterationsepsilon: The target cost for the model to stop training
suppressOutput
: An option whether or not to display the number of iterations and the cost
:predict()
predict(featureMatrix: matrix, meanMatrix: matrix, probabilitiesMatrix: matrix): number, matrix
Arguments:
featureMatrix
: The matrix containing values for the model to predict onmodelParameters
: The matrix generated from training the model
Notes:
Expectation Maximization Model can handle feature matrices containing positive integers values between 0 and 125 only. The reason is that those numbers are used for factorials and any higher will cause the model incapable of calculating it - leading to an infinity value.
Untested. May give wrong model. Use at your own risk. (I am new at understanding this model)