Class DefaultMachineLearning

Object
DefaultMachineLearning
All Implemented Interfaces:
MachineLearning

public class DefaultMachineLearning
extends Object
implements MachineLearning
  • Method Details

    • logisticRegression

      public DRes<ArrayList<DRes<SFixed>>> logisticRegression​(Matrix<DRes<SFixed>> data, ArrayList<DRes<SFixed>> expected, double[] beta, IntToDoubleFunction rate, int epochs)
      Description copied from interface: MachineLearning
      Estimate the parameters of a logistic model using gradient descent.
      Specified by:
      logisticRegression in interface MachineLearning
      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 DRes<MLP> fit​(MLP network, List<ArrayList<DRes<SFixed>>> data, List<ArrayList<DRes<SFixed>>> labels, int epochs, double learningRate)
      Description copied from interface: MachineLearning
      Fit the given multilayer perceptron to a dataset using back propagation.
      Specified by:
      fit in interface MachineLearning
      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 DRes<SInt> predict​(MLP network, ArrayList<DRes<SFixed>> input)
      Description copied from interface: MachineLearning
      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.
      Specified by:
      predict in interface MachineLearning
      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.