Package dk.alexandra.fresco.stat
Class DefaultMachineLearning
java.lang.Object
dk.alexandra.fresco.stat.DefaultMachineLearning
- All Implemented Interfaces:
MachineLearning
public class DefaultMachineLearning extends Object implements MachineLearning
-
Method Summary
Modifier and Type Method Description dk.alexandra.fresco.framework.DRes<MLP>fit(MLP network, List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> data, List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> labels, int epochs, double learningRate)Fit the given multilayer perceptron to a dataset using back propagation.dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>>logisticRegression(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> data, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> expected, double[] beta, IntToDoubleFunction rate, int epochs)Estimate the parameters of a logistic model using gradient descent.dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.framework.value.SInt>predict(MLP network, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> input)Assuming that the given MLP has n output neurons, this function applies the network to the given input and finds the index of the output i with 0 ≤ i < n containing the largest number.
-
Method Details
-
logisticRegression
public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> logisticRegression(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> data, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> expected, double[] beta, IntToDoubleFunction rate, int epochs)Description copied from interface:MachineLearningEstimate the parameters of a logistic model using gradient descent.- Specified by:
logisticRegressionin interfaceMachineLearning- Parameters:
data- The data represented as a matrix with entry as rows.expected- The expected outcome for each entry represented as a list. Each entry should be either 0 or 1.beta- The initial guess for the parameters of the model with the first being the constant term.rate- The learning rate used by the gradient descent algorithm as a function of the iteration number.epochs- The number of iterations.- Returns:
- An approximation of the parameters of a logistic model fitting the given data.
-
fit
public dk.alexandra.fresco.framework.DRes<MLP> fit(MLP network, List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> data, List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> labels, int epochs, double learningRate)Description copied from interface:MachineLearningFit the given multilayer perceptron to a dataset using back propagation.- Specified by:
fitin interfaceMachineLearning- Parameters:
network- The mlp to fit.data- The dataset to use as input.labels- The expected outputs.epochs- The number of epochs, ie. iterations through the entire dataset.learningRate- The learning rate.- Returns:
- A new MLP with updated weights.
-
predict
public dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.framework.value.SInt> predict(MLP network, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> input)Description copied from interface:MachineLearningAssuming that the given MLP has n output neurons, this function applies the network to the given input and finds the index of the output i with 0 ≤ i < n containing the largest number.- Specified by:
predictin interfaceMachineLearning- Parameters:
network- The multi-layer perceptron to use for the prediction.input- The input.- Returns:
- The index of the largest element in the output vector.
-