public class Linear
extends java.lang.Object
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 and Description |
---|
Linear() |
Modifier and Type | Method and Description |
---|---|
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(java.io.File modelFile)
Loads the model from the file with ISO-8859-1 charset.
|
static Model |
loadModel(java.io.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.
|
static void |
saveModel(java.io.File modelFile,
Model model)
Writes the model to the file with ISO-8859-1 charset.
|
static void |
saveModel(java.io.Writer modelOutput,
Model model)
Writes the model to the modelOutput.
|
static void |
setDebugOutput(java.io.PrintStream debugOutput) |
static Model |
train(Problem prob,
Parameter param) |
public static void crossValidation(Problem prob, Parameter param, int nr_fold, int[] target)
target
- predicted classespublic static double[] copyOf(double[] original, int newLength)
public static int[] copyOf(int[] original, int newLength)
public static Model loadModel(java.io.Reader inputReader) throws java.io.IOException
Locale.ENGLISH
for number formatting.
Note: The inputReader is closed after reading or in case of an exception.
java.io.IOException
public static Model loadModel(java.io.File modelFile) throws java.io.IOException
Locale.ENGLISH
for number formatting.java.io.IOException
public static int predict(Model model, FeatureNode[] x)
public static int predictProbability(Model model, FeatureNode[] x, double[] prob_estimates) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if model is not probabilistic (see Model.isProbabilityModel()
)public static int predictValues(Model model, FeatureNode[] x, double[] dec_values)
public static void saveModel(java.io.Writer modelOutput, Model model) throws java.io.IOException
Locale.ENGLISH
for number formatting.
Note: The modelOutput is closed after reading or in case of an exception.
java.io.IOException
public static void saveModel(java.io.File modelFile, Model model) throws java.io.IOException
Locale.ENGLISH
for number formatting.java.io.IOException
public static Model train(Problem prob, Parameter param)
java.lang.IllegalArgumentException
- if the feature nodes of prob are not sorted in ascending orderpublic static void disableDebugOutput()
public static void enableDebugOutput()
public static void setDebugOutput(java.io.PrintStream debugOutput)
public static void resetRandom()