Class SVM

  • All Implemented Interfaces:
    java.io.Serializable

    public class SVM
    extends SupervisedLearning
    Implementation of the SVM using the SMO algorithm. Based on the original implementation of:
    X. Jiang and H. Yu. SVM-JAVA: A Java implementation of the SMO (Sequential Minimal Optimization) for training SVM.
    Department of Computer Science and Engineering, Pohang University of Science and Technology (POSTECH), http://iis.hwanjoyu.org/svm-java, 2008. The code was adapted to the data structures and architecture of the libai. Some little optimization was made.
    See Also:
    Serialized Form
    • Constructor Detail

      • SVM

        public SVM​(Kernel _kernel)
      • SVM

        public SVM​(Kernel _kernel,
                   java.util.Random rand)
    • Method Detail

      • setTrainingParam

        public void setTrainingParam​(int param,
                                     double paramValue)
      • train

        public void train​(Column[] patterns,
                          Column[] answers,
                          double alpha,
                          int epochs,
                          int offset,
                          int length,
                          double minerror)
        Description copied from class: NeuralNetwork
        Trains this neural network with the list of patterns and the expected answers.

        Use the learning rate alpha for many epochs. Take length patterns from the position offset until the minerror is reached.

        patterns and answers must be arrays of non-null column matrices

        Specified by:
        train in class NeuralNetwork
        Parameters:
        patterns - The patterns to be learned.
        answers - The expected answers.
        alpha - The learning rate.
        epochs - The maximum number of iterations
        offset - The first pattern position
        length - How many patterns will be used.
        minerror - The minimal error expected.
      • simulate

        public Column simulate​(Column pattern)
        Description copied from class: NeuralNetwork
        Calculates the output for the pattern.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - Pattern to use as input.
        Returns:
        The output for the neural network.
      • simulate

        public void simulate​(Column pattern,
                             Column result)
        Description copied from class: NeuralNetwork
        Calculates the output for the pattern and left the result in result.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - Pattern to use as input.
        result - The output for the input.
      • error

        public double error​(Column[] patterns,
                            Column[] answers,
                            int offset,
                            int length)
        Description copied from class: NeuralNetwork
        Calculates the mean quadratic error. It is the standard error metric for neural networks. Just a few networks needs a different type of error metric.

        patterns and answers must be arrays of non-null column matrices

        NOTE: Assertions of the dimensions are made with assert statement. You must enable this on runtime to be effective.

        Overrides:
        error in class NeuralNetwork
        Parameters:
        patterns - The array with the patterns to test
        answers - The array with the expected answers for the patterns.
        offset - The initial position inside the array.
        length - How many patterns must be taken from the offset.
        Returns:
        The mean quadratic error.