Class LinearSvc

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

public final class LinearSvc extends Object
Linear support vector classification with the squared hinge loss, one-vs-rest, after scikit-learn's LinearSVC (liblinear, intercept_scaling 1): for each class it minimises ||[w, b]||^2 / 2 + C sum_i max(0, 1 - y_i (w . x_i + b))^2, the intercept penalised like a weight, with L-BFGS (the objective is smooth).
  • Constructor Details

    • LinearSvc

      public LinearSvc(float c, int maxIter)
      A classifier with penalty c and at most maxIter iterations.
    • LinearSvc

      public LinearSvc()
      A classifier with scikit-learn's defaults: C 1, 1000 iterations.
  • Method Details

    • fit

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

      public Tensor coef()
      The weights: [1, features] for two classes, else [classes, features].
    • intercept

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

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

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