Class Linear

java.lang.Object
de.bwaldvogel.liblinear.Linear

public class Linear
extends java.lang.Object

Java port of liblinear

The usage should be pretty similar to the C version of liblinear.

Please consider reading the README file of liblinear.

The port was done by Benedikt Waldvogel (mail at bwaldvogel.de)

  • Constructor Details

  • Method Details

    • crossValidation

      public static void crossValidation​(Problem prob, Parameter param, int nr_fold, double[] target)
      Parameters:
      target - predicted classes
    • findParameters

      public static ParameterSearchResult findParameters​(Problem prob, Parameter param, int nr_fold, double start_C, double start_p)
    • loadModel

      public static Model loadModel​(java.io.Reader inputReader) throws java.io.IOException
      Loads the model from inputReader. It uses Locale.ENGLISH for number formatting.

      Note: The inputReader is NOT closed after reading or in case of an exception.

      Throws:
      java.io.IOException
    • loadModel

      public static Model loadModel​(java.io.File modelFile) throws java.io.IOException
      Deprecated.
      use loadModel(Path) instead
      Loads the model from the file with ISO-8859-1 charset. It uses Locale.ENGLISH for number formatting.
      Throws:
      java.io.IOException
    • loadModel

      public static Model loadModel​(java.nio.file.Path modelPath) throws java.io.IOException
      Loads the model from the file with ISO-8859-1 charset. It uses Locale.ENGLISH for number formatting.
      Throws:
      java.io.IOException
    • predict

      public static double predict​(Model model, Feature[] x)
    • predictProbability

      public static double predictProbability​(Model model, Feature[] x, double[] prob_estimates) throws java.lang.IllegalArgumentException
      Throws:
      java.lang.IllegalArgumentException - if model is not probabilistic (see Model.isProbabilityModel())
    • predictValues

      public static double predictValues​(Model model, Feature[] x, double[] dec_values)
    • saveModel

      public static void saveModel​(java.io.Writer modelOutput, Model model) throws java.io.IOException
      Writes the model to the modelOutput. It uses Locale.ENGLISH for number formatting.

      Note: The modelOutput is closed after reading or in case of an exception.

      Throws:
      java.io.IOException
    • saveModel

      public static void saveModel​(java.io.File modelFile, Model model) throws java.io.IOException
      Deprecated.
      Writes the model to the file with ISO-8859-1 charset. It uses Locale.ENGLISH for number formatting.
      Throws:
      java.io.IOException
    • saveModel

      public static void saveModel​(java.nio.file.Path modelPath, Model model) throws java.io.IOException
      Writes the model to the file with ISO-8859-1 charset. It uses Locale.ENGLISH for number formatting.
      Throws:
      java.io.IOException
    • train

      public static Model train​(Problem prob, Parameter param)
      Throws:
      java.lang.IllegalArgumentException - if the feature nodes of prob are not sorted in ascending order
    • find_parameter_C

      public static ParameterCSearchResult find_parameter_C​(Problem prob, Parameter param_tmp, double start_C, double max_C, int[] fold_start, int[] perm, Problem[] subprob, int nr_fold)
    • disableDebugOutput

      public static void disableDebugOutput()
    • enableDebugOutput

      public static void enableDebugOutput()
    • setDebugOutput

      public static void setDebugOutput​(java.io.PrintStream debugOutput)
    • getVersion

      public static int getVersion()
    • resetRandom

      public static void resetRandom()
      resets the PRNG this is i.a. needed for regression testing (eg. the Weka wrapper)