Package de.bwaldvogel.liblinear
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 Summary
Constructors Constructor Description Linear() -
Method Summary
Modifier and Type Method Description static voidcrossValidation(Problem prob, Parameter param, int nr_fold, double[] target)static voiddisableDebugOutput()static voidenableDebugOutput()static ParameterCSearchResultfind_parameter_C(Problem prob, Parameter param_tmp, double start_C, double max_C, int[] fold_start, int[] perm, Problem[] subprob, int nr_fold)static ParameterSearchResultfindParameters(Problem prob, Parameter param, int nr_fold, double start_C, double start_p)static intgetVersion()static ModelloadModel(java.io.File modelFile)Deprecated.useloadModel(Path)insteadstatic ModelloadModel(java.io.Reader inputReader)Loads the model from inputReader.static ModelloadModel(java.nio.file.Path modelPath)Loads the model from the file with ISO-8859-1 charset.static doublepredict(Model model, Feature[] x)static doublepredictProbability(Model model, Feature[] x, double[] prob_estimates)static doublepredictValues(Model model, Feature[] x, double[] dec_values)static voidresetRandom()resets the PRNG this is i.a.static voidsaveModel(java.io.File modelFile, Model model)Deprecated.usesaveModel(Path, Model)insteadstatic voidsaveModel(java.io.Writer modelOutput, Model model)Writes the model to the modelOutput.static voidsaveModel(java.nio.file.Path modelPath, Model model)Writes the model to the file with ISO-8859-1 charset.static voidsetDebugOutput(java.io.PrintStream debugOutput)static Modeltrain(Problem prob, Parameter param)
-
Constructor Details
-
Linear
public Linear()
-
-
Method Details
-
crossValidation
- Parameters:
target- predicted classes
-
findParameters
public static ParameterSearchResult findParameters(Problem prob, Parameter param, int nr_fold, double start_C, double start_p) -
loadModel
Loads the model from inputReader. It usesLocale.ENGLISHfor number formatting.Note: The inputReader is NOT closed after reading or in case of an exception.
- Throws:
java.io.IOException
-
loadModel
Deprecated.useloadModel(Path)insteadLoads the model from the file with ISO-8859-1 charset. It usesLocale.ENGLISHfor number formatting.- Throws:
java.io.IOException
-
loadModel
Loads the model from the file with ISO-8859-1 charset. It usesLocale.ENGLISHfor number formatting.- Throws:
java.io.IOException
-
predict
-
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 (seeModel.isProbabilityModel())
-
predictValues
-
saveModel
Writes the model to the modelOutput. It usesLocale.ENGLISHfor number formatting.Note: The modelOutput is closed after reading or in case of an exception.
- Throws:
java.io.IOException
-
saveModel
Deprecated.usesaveModel(Path, Model)insteadWrites the model to the file with ISO-8859-1 charset. It usesLocale.ENGLISHfor number formatting.- Throws:
java.io.IOException
-
saveModel
Writes the model to the file with ISO-8859-1 charset. It usesLocale.ENGLISHfor number formatting.- Throws:
java.io.IOException
-
train
- 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)
-