Class Linear
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.ProstateFramework.liblinearsvm.Linear
Copyright (c) 2007-2014 The LIBLINEAR Project.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither name of copyright holders nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Java port of liblinear 1.51
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.51
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classused as complex return type -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublestatic int(package private) static voidstatic double[]copyOf(double[] original, int newLength) Java5 'backport' of Arrays.copyOfstatic int[]copyOf(int[] original, int newLength) Java5 'backport' of Arrays.copyOfstatic voidcrossValidation(Problem prob, Parameter param, int nr_fold, int[] target) static voidstatic voidprivate static intGETI(byte[] y, int i) private static Linear.GroupClassesReturngroupClasses(Problem prob, int[] perm) (package private) static void(package private) static voidstatic ModelLoads the model from the file with ISO-8859-1 charset.static ModelLoads the model from inputReader.static intpredict(Model model, FeatureNode[] x) static intpredictProbability(Model model, FeatureNode[] x, double[] prob_estimates) static intpredictValues(Model model, FeatureNode[] x, double[] dec_values) (package private) static voidstatic voidresets the PRNG this is i.a. needed for regression testing (eg. the Weka wrapper)static voidWrites the model to the file with ISO-8859-1 charset.static voidWrites the model to the modelOutput.static voidsetDebugOutput(PrintStream debugOutput) private static voidsolve_l1r_l2_svc(Problem prob_col, double[] w, double eps, double Cp, double Cn) A coordinate descent algorithm for L1-regularized L2-loss support vector classificationprivate static voidsolve_l1r_lr(Problem prob_col, double[] w, double eps, double Cp, double Cn) A coordinate descent algorithm for L1-regularized logistic regression problemsprivate static voidsolve_l2r_l1l2_svc(Problem prob, double[] w, double eps, double Cp, double Cn, SolverType solver_type) A coordinate descent algorithm for L1-loss and L2-loss SVM dual problems(package private) static voidswap(double[] array, int idxA, int idxB) (package private) static voidswap(int[] array, int idxA, int idxB) (package private) static voidswap(IntArrayPointer array, int idxA, int idxB) static Modelprivate static void(package private) static Problem
-
Field Details
-
FILE_CHARSET
-
DEFAULT_LOCALE
-
OUTPUT_MUTEX
-
DEBUG_OUTPUT
-
NL
platform-independent new-line string -
DEFAULT_RANDOM_SEED
private static final long DEFAULT_RANDOM_SEED- See Also:
-
random
-
-
Constructor Details
-
Linear
public Linear()
-
-
Method Details
-
crossValidation
- Parameters:
target- predicted classes
-
groupClasses
-
info
-
info
-
atof
- Parameters:
s- the string to parse for the double value- Throws:
IllegalArgumentException- if s is empty or represents NaN or InfinityNumberFormatException- seeDouble.parseDouble(String)
-
atoi
- Parameters:
s- the string to parse for the integer value- Throws:
IllegalArgumentException- if s is emptyNumberFormatException- seeInteger.parseInt(String)
-
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
Loads the model from inputReader. It usesfor number formatting.invalid reference
Locale.ENGLISHNote: The inputReader is closed after reading or in case of an exception.
- Throws:
IOException
-
loadModel
Loads the model from the file with ISO-8859-1 charset. It usesfor number formatting.invalid reference
Locale.ENGLISH- Throws:
IOException
-
closeQuietly
-
predict
-
predictProbability
-
predictValues
-
printf
- Throws:
IOException
-
saveModel
Writes the model to the modelOutput. It usesfor number formatting.invalid reference
Locale.ENGLISHNote: The modelOutput is closed after reading or in case of an exception.
- Throws:
IOException
-
saveModel
Writes the model to the file with ISO-8859-1 charset. It usesfor number formatting.invalid reference
Locale.ENGLISH- Throws:
IOException
-
GETI
private static int GETI(byte[] y, int i) -
solve_l2r_l1l2_svc
private static void solve_l2r_l1l2_svc(Problem prob, double[] w, double eps, double Cp, double Cn, SolverType solver_type) A coordinate descent algorithm for L1-loss and L2-loss SVM dual problemsmin_\alpha 0.5(\alpha^T (Q + D)\alpha) - e^T \alpha, s.t. 0 invalid input: '<'= alpha_i invalid input: '<'= upper_bound_i, where Qij = yi yj xi^T xj and D is a diagonal matrix In L1-SVM case: upper_bound_i = Cp if y_i = 1 upper_bound_i = Cn if y_i = -1 D_ii = 0 In L2-SVM case: upper_bound_i = INF D_ii = 1/(2*Cp) if y_i = 1 D_ii = 1/(2*Cn) if y_i = -1 Given: x, y, Cp, Cn eps is the stopping tolerance solution will be put in w -
solve_l1r_l2_svc
private static void solve_l1r_l2_svc(Problem prob_col, double[] w, double eps, double Cp, double Cn) A coordinate descent algorithm for L1-regularized L2-loss support vector classificationmin_w \sum |wj| + C \sum max(0, 1-yi w^T xi)^2, Given: x, y, Cp, Cn eps is the stopping tolerance solution will be put in w
-
solve_l1r_lr
A coordinate descent algorithm for L1-regularized logistic regression problemsmin_w \sum |wj| + C \sum log(1+exp(-yi w^T xi)), Given: x, y, Cp, Cn eps is the stopping tolerance solution will be put in w
-
transpose
-
swap
static void swap(double[] array, int idxA, int idxB) -
swap
static void swap(int[] array, int idxA, int idxB) -
swap
-
train
- Throws:
IllegalArgumentException- if the feature nodes of prob are not sorted in ascending order
-
train_one
-
disableDebugOutput
public static void disableDebugOutput() -
enableDebugOutput
public static void enableDebugOutput() -
setDebugOutput
-
resetRandom
public static void resetRandom()resets the PRNG this is i.a. needed for regression testing (eg. the Weka wrapper)
-