NaiveBayes is an supervised machine learning model that predicts which classes that the input belongs to using probability.
Code Sample
local featureMatrix = {
{123, -100},
{30, 40},
{12, 43},
{95, 90},
}
local labelVector = {
{1},
{3},
{2},
{1},
}
local testFeatureMatrix = {
{32, 12},
}
local probabilitiesMatrix, meanMatrix, standardDeviationMatrix, classesList = MachineLL.NaiveBayes:train(featureMatrix, labelVector)
local class, probabilityVector = MachineLL.NaiveBayes:predict(testFeatureMatrix, probabilitiesMatrix, meanMatrix, standardDeviationMatrix, classesList)
Functions
:train()
train(featureMatrix: matrix, labelVector: matrix): matrix, matrix, matrix, []
Arguments:
featureMatrix
: The matrix containing values for the model to train onlabelVector
: The vector containing actual values that are as a result of relationship with featureMatrix
:predict()
predict(featureMatrix: matrix, probabilitiesMatrix: matrix, meanMatrix: matrix, standardDeviationMatrix: matrix, classesList: []): number, matrix
Arguments:
featureMatrix
: The matrix containing values for the model to predict onprobabilitiesMatrix, meanMatrix, standardDeviationMatrix
: The matrices generated from training the modelclassesList
: The list containing all classes generated from training the model
Notes:
Untested. May give wrong model. Use at your own risk. (I am new at understanding this model)