org.opentox.util.libSVM
Class svm_train

java.lang.Object
  extended by org.opentox.util.libSVM.svm_train

public class svm_train
extends java.lang.Object

Training of SVM classification and regression models.

Important: The original source code belongs to LibSVM


Reference: Chih-Chung Chang and Chih-Jen Lin, LIBSVM: a library for support vector machines, 2001, Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm

Copyright:

 Copyright (c) 2000-2009 Chih-Chung Chang and Chih-Jen Lin
 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.
 

Author:
Sopasakis Pantelis (Minor Modifications of the original code)

Field Summary
private  int cross_validation
           
private  java.lang.String error_msg
           
private  java.lang.String input_file_name
           
private  libsvm.svm_model model
           
private  java.lang.String model_file_name
           
private  int nr_fold
           
private  libsvm.svm_parameter param
           
private  libsvm.svm_problem prob
           
private static long serialVersionUID
           
 
Constructor Summary
svm_train()
           
 
Method Summary
private static double atof(java.lang.String s)
           
private static int atoi(java.lang.String s)
           
private  void do_cross_validation()
           
private static void exit_with_help()
           
static void main(java.lang.String[] argv)
          Usage: svm_train [options] training_set_file [model_file]"
options:
-s svm_type : set type of SVM (default 0)
0 -- C-SVC 1 -- nu-SVC 2 -- one-class SVM 3 -- epsilon-SVR 4 -- nu-SVR -t kernel_type : set type of kernel function (default 2)
0 -- linear: u'*v 1 -- polynomial: (gamma*u'*v + coef0)^degree 2 -- radial basis function: exp(-gamma*|u-v|^2) 3 -- sigmoid: tanh(gamma*u'*v + coef0) 4 -- precomputed kernel (kernel values in training_set_file) -d degree : set degree in kernel function (default 3)

-g gamma : set gamma in kernel function (default 1/k)

-r coef0 : set coef0 in kernel function (default 0)

-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)

-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)\n"

-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\n"

-m cachesize : set cache memory size in MB (default 100)

-e epsilon : set tolerance of termination criterion (default 0.001)

-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)

-b probability_estimates : whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)

-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)

-v n : n-fold cross validation mode

-q : quiet mode (no outputs)
private  void parse_command_line(java.lang.String[] argv)
           
private  void read_problem()
           
private  void run(java.lang.String[] argv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

param

private libsvm.svm_parameter param

prob

private libsvm.svm_problem prob

model

private libsvm.svm_model model

input_file_name

private java.lang.String input_file_name

model_file_name

private java.lang.String model_file_name

error_msg

private java.lang.String error_msg

cross_validation

private int cross_validation

nr_fold

private int nr_fold
Constructor Detail

svm_train

public svm_train()
Method Detail

exit_with_help

private static void exit_with_help()

do_cross_validation

private void do_cross_validation()

run

private void run(java.lang.String[] argv)
          throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] argv)
                 throws java.io.IOException
Usage: svm_train [options] training_set_file [model_file]"
options:
-s svm_type : set type of SVM (default 0)
-t kernel_type : set type of kernel function (default 2)
-d degree : set degree in kernel function (default 3)

-g gamma : set gamma in kernel function (default 1/k)

-r coef0 : set coef0 in kernel function (default 0)

-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)

-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)\n"

-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\n"

-m cachesize : set cache memory size in MB (default 100)

-e epsilon : set tolerance of termination criterion (default 0.001)

-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)

-b probability_estimates : whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)

-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)

-v n : n-fold cross validation mode

-q : quiet mode (no outputs)

Parameters:
argv -
Throws:
java.io.IOException

atof

private static double atof(java.lang.String s)

atoi

private static int atoi(java.lang.String s)

parse_command_line

private void parse_command_line(java.lang.String[] argv)

read_problem

private void read_problem()
                   throws java.io.IOException
Throws:
java.io.IOException