Class SparseLogisticRegression.Binomial

All Implemented Interfaces:
Serializable, ToDoubleFunction<SparseArray>, ToIntFunction<SparseArray>, Classifier<SparseArray>
Enclosing class:
SparseLogisticRegression

public static class SparseLogisticRegression.Binomial extends SparseLogisticRegression
Binomial logistic regression. The dependent variable is nominal of two levels.
See Also:
  • Constructor Details

    • Binomial

      public Binomial(double[] w, double L, double lambda, IntSet labels)
      Constructor.
      Parameters:
      w - the weights.
      L - the log-likelihood of learned model.
      lambda - lambda > 0 gives a "regularized" estimate of linear weights which often has superior generalization performance, especially when the dimensionality is high.
      labels - the class label encoder.
  • Method Details

    • coefficients

      public double[] coefficients()
      Returns an array of size (p+1) containing the linear weights of binary logistic regression, where p is the dimension of feature vectors. The last element is the weight of bias.
      Returns:
      the linear weights.
    • score

      public double score(SparseArray x)
      Description copied from interface: Classifier
      The raw prediction score.
      Parameters:
      x - the instance to be classified.
      Returns:
      the raw prediction score.
    • predict

      public int predict(SparseArray x)
      Description copied from interface: Classifier
      Predicts the class label of an instance.
      Parameters:
      x - the instance to be classified.
      Returns:
      the predicted class label.
    • predict

      public int predict(SparseArray x, double[] posteriori)
      Description copied from interface: Classifier
      Predicts the class label of an instance and also calculate a posteriori probabilities. Classifiers may NOT support this method since not all classification algorithms are able to calculate such a posteriori probabilities.
      Parameters:
      x - an instance to be classified.
      posteriori - a posteriori probabilities on output.
      Returns:
      the predicted class label
    • update

      public void update(SparseArray x, int y)
      Description copied from interface: Classifier
      Online update the classifier with a new training instance. In general, this method may be NOT multi-thread safe.
      Parameters:
      x - the training instance.
      y - the training label.