de.bwaldvogel.liblinear
Class Linear

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

public class Linear
extends 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)

Version:
1.8

Constructor Summary
Linear()
           
 
Method Summary
static double[] copyOf(double[] original, int newLength)
          Java5 'backport' of Arrays.copyOf
static int[] copyOf(int[] original, int newLength)
          Java5 'backport' of Arrays.copyOf
static void crossValidation(Problem prob, Parameter param, int nr_fold, int[] target)
           
static void disableDebugOutput()
           
static void enableDebugOutput()
           
static Model loadModel(File modelFile)
          Loads the model from the file with ISO-8859-1 charset.
static Model loadModel(Reader inputReader)
          Loads the model from inputReader.
static int predict(Model model, FeatureNode[] x)
           
static int predictProbability(Model model, FeatureNode[] x, double[] prob_estimates)
           
static int predictValues(Model model, FeatureNode[] x, double[] dec_values)
           
static void resetRandom()
          resets the PRNG this is i.a. needed for regression testing (eg. the Weka wrapper)
static void saveModel(File modelFile, Model model)
          Writes the model to the file with ISO-8859-1 charset.
static void saveModel(Writer modelOutput, Model model)
          Writes the model to the modelOutput.
static void setDebugOutput(PrintStream debugOutput)
           
static Model train(Problem prob, Parameter param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Linear

public Linear()
Method Detail

crossValidation

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

copyOf

public static double[] copyOf(double[] original,
                              int newLength)
Java5 'backport' of Arrays.copyOf


copyOf

public static int[] copyOf(int[] original,
                           int newLength)
Java5 'backport' of Arrays.copyOf


loadModel

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

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

Throws:
IOException

loadModel

public static Model loadModel(File modelFile)
                       throws IOException
Loads the model from the file with ISO-8859-1 charset. It uses Locale.ENGLISH for number formatting.

Throws:
IOException

predict

public static int predict(Model model,
                          FeatureNode[] x)

predictProbability

public static int predictProbability(Model model,
                                     FeatureNode[] x,
                                     double[] prob_estimates)
                              throws IllegalArgumentException
Throws:
IllegalArgumentException - if model is not probabilistic (see Model.isProbabilityModel())

predictValues

public static int predictValues(Model model,
                                FeatureNode[] x,
                                double[] dec_values)

saveModel

public static void saveModel(Writer modelOutput,
                             Model model)
                      throws 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:
IOException

saveModel

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

Throws:
IOException

train

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

disableDebugOutput

public static void disableDebugOutput()

enableDebugOutput

public static void enableDebugOutput()

setDebugOutput

public static void setDebugOutput(PrintStream debugOutput)

resetRandom

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



Copyright © 2011. All Rights Reserved.