Class LIBSVM

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class LIBSVM
    extends AlgorithmBase
    Copyright (c) 2000-2023 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. Libsvm is a simple, easy-to-use, and efficient software for SVM classification and regression. It solves C-SVM classification, nu-SVM classification, one-class-SVM, epsilon-SVM regression, and nu-SVM regression. It also provides an automatic model selection tool for C-SVM classification. This document explains the use of libsvm. Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines. ACM Transactions on Intelligent Systems and Technology, 2:27:1--27:27, 2011. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm LIBSVM implementation document is available at http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf
    • Field Detail

      • rand

        public final java.util.Random rand
      • svm_type_table

        final java.lang.String[] svm_type_table
      • kernel_type_table

        final java.lang.String[] kernel_type_table
      • 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
      • line

        private java.lang.String line
      • lower

        private double lower
      • upper

        private double upper
      • y_lower

        private double y_lower
      • y_upper

        private double y_upper
      • y_scaling

        private boolean y_scaling
      • feature_max

        private double[] feature_max
      • feature_min

        private double[] feature_min
      • y_max

        private double y_max
      • y_min

        private double y_min
      • max_index

        private int max_index
      • num_nonzeros

        private long num_nonzeros
      • new_num_nonzeros

        private long new_num_nonzeros
    • Constructor Detail

      • LIBSVM

        public LIBSVM()
    • Method Detail

      • info

        void info​(java.lang.String s)
      • sigmoid_train

        private void sigmoid_train​(int l,
                                   double[] dec_values,
                                   double[] labels,
                                   double[] probAB)
      • sigmoid_predict

        private double sigmoid_predict​(double decision_value,
                                       double A,
                                       double B)
      • multiclass_probability

        private void multiclass_probability​(int k,
                                            double[][] r,
                                            double[] p)
      • predict_one_class_probability

        private double predict_one_class_probability​(LIBSVM.svm_model model,
                                                     double dec_value)
      • svm_group_classes

        private void svm_group_classes​(LIBSVM.svm_problem prob,
                                       int[] nr_class_ret,
                                       int[][] label_ret,
                                       int[][] start_ret,
                                       int[][] count_ret,
                                       int[] perm)
      • svm_get_labels

        public void svm_get_labels​(LIBSVM.svm_model model,
                                   int[] label)
      • svm_get_sv_indices

        public void svm_get_sv_indices​(LIBSVM.svm_model model,
                                       int[] indices)
      • svm_get_svr_probability

        public double svm_get_svr_probability​(LIBSVM.svm_model model)
      • powi

        private double powi​(double base,
                            int times)
      • svm_save_model

        public void svm_save_model​(java.lang.String model_file_name,
                                   LIBSVM.svm_model model)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • read_model_header

        private boolean read_model_header​(java.io.BufferedReader fp,
                                          LIBSVM.svm_model model)
      • svm_load_model

        public LIBSVM.svm_model svm_load_model​(java.lang.String model_file_name)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • svm_load_model

        public LIBSVM.svm_model svm_load_model​(java.io.BufferedReader fp)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • svm_check_probability_model

        public int svm_check_probability_model​(LIBSVM.svm_model model)
      • train_exit_with_help

        private void train_exit_with_help()
      • do_cross_validation

        private void do_cross_validation()
      • run_svm_train

        public LIBSVM.svm_model run_svm_train​(double[][] Xin,
                                              double[] y,
                                              java.lang.String[] argv)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • run_svm_train

        public void run_svm_train​(java.lang.String[] argv)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • atof

        private double atof​(java.lang.String s)
      • atoi

        private int atoi​(java.lang.String s)
      • parse_command_line

        private void parse_command_line​(java.lang.String[] argv,
                                        boolean haveFile)
      • read_XY

        private void read_XY​(double[][] Xin,
                             double[] y)
      • read_problem

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

        private void predict​(java.io.BufferedReader input,
                             java.io.DataOutputStream output,
                             LIBSVM.svm_model model,
                             int predict_probability)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • predict_exit_with_help

        private void predict_exit_with_help()
      • run_svm_predict

        public void run_svm_predict​(java.lang.String[] argv)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • scale_exit_with_help

        private void scale_exit_with_help()
      • rewind

        private java.io.BufferedReader rewind​(java.io.BufferedReader fp,
                                              java.lang.String filename)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • output_target

        private void output_target​(double value)
      • output

        private void output​(int index,
                            double value)
      • readline

        private java.lang.String readline​(java.io.BufferedReader fp)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • run_svm_scale

        public void run_svm_scale​(java.lang.String[] argv)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • run_svm_toy

        public void run_svm_toy​(java.lang.String[] args)
      • runAlgorithm

        public void runAlgorithm()
        Description copied from class: AlgorithmBase
        Actually runs the algorithm. Implemented by inheriting algorithms.
        Specified by:
        runAlgorithm in class AlgorithmBase