Class LogisticRegression

java.lang.Object
ai.beestream.jitnn.ml.LogisticRegression

public final class LogisticRegression extends Object
L2-regularised logistic regression fitted with L-BFGS, after scikit-learn's LogisticRegression (lbfgs): it minimises C sum_i loss_i + ||W||^2 / 2 with the intercept unpenalised; a sigmoid for two classes, the multinomial (softmax) loss for more.
  • Constructor Details

    • LogisticRegression

      public LogisticRegression(float c, int maxIter)
      A classifier with inverse regularisation strength c and at most maxIter L-BFGS iterations.
    • LogisticRegression

      public LogisticRegression()
      A classifier with C 1 and 500 iterations.
  • Method Details

    • fit

      public LogisticRegression fit(Tensor x, int[] y)
      Fits samples x [n, features] and labels y.
    • coef

      public Tensor coef()
      Coefficients [1, d] for two classes, [c, d] otherwise.
    • intercept

      public Tensor intercept()
      The intercepts, one per row of the weights.
    • decisionFunction

      public Tensor decisionFunction(Tensor x)
      The decision values x W^T + b of each sample.
    • predictProba

      public Tensor predictProba(Tensor x)
      Class probabilities [m, c].
    • predict

      public int[] predict(Tensor x)
      The most probable label of each sample.