LogisticRegression is a supervised machine learning model that predicts values of 0 and 1 only.
Code Sample
local featureMatrix = {
{ 0, 0},
{10, 10},
{-3, -3},
{-2, -2},
{ 2, 2},
{ 1, 1},
{-1, -1},
{ 3, 3},
{-8, -8},
}
local labelVectorLogistic = {
{1},
{1},
{0},
{0},
{1},
{1},
{0},
{1},
{0}
}
local testFeatureMatrix = {
{-3, -3},
}
local modelParameters, cost = MachineLL.LogisticRegression:train(featureMatrix, labelVectorLogistic , nil, nil, nil, 0.1)
local result = MachineLL.LogisticRegression:predict(testFeatureMatrix , modelParameters)
Functions
:train()
train(featureMatrix: matrix, labelVector: matrix, maxNumberOfIterations: integer, learningRate: number, sigmoidFunction : string, targetCost: number, suppressOutput: boolean): matrix, number
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 featureMatrixmaxNumberOfIterations
: Maximum number of iterationslearningRate
: The learning rate for the model (values between 0 and 1 is recommended)sigmoidFunction
: The function that the model will use to train. sigmoidFunction available are “sigmoid”targetCost
: The target cost for the model to stop trainingsuppressOutput
: An option whether or not to display the number of iterations and the cost
:predict()
predict(featureMatrix: matrix, modelParameters: matrix): number
Arguments:
featureMatrix
: The matrix containing values for the model to predict onmodelParameters
: The matrix generated from training the model