Package libai.nn.supervised
Class SVM
- java.lang.Object
-
- libai.nn.NeuralNetwork
-
- libai.nn.supervised.SupervisedLearning
-
- libai.nn.supervised.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
-
-
Field Summary
Fields Modifier and Type Field Description static intPARAM_Cstatic intPARAM_EPSILONstatic intPARAM_TOLERANCEprotected static SymmetricSignssign-
Fields inherited from class libai.nn.NeuralNetwork
plotter, progress, random
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleerror(Column[] patterns, Column[] answers, int offset, int length)Calculates the mean quadratic error.voidsetTrainingParam(int param, double paramValue)Columnsimulate(Column pattern)Calculates the output for thepattern.voidsimulate(Column pattern, Column result)Calculates the output for thepatternand left the result inresult.voidtrain(Column[] patterns, Column[] answers, double alpha, int epochs, int offset, int length, double minerror)Trains this neural network with the list ofpatternsand the expectedanswers.protected voidvalidatePreconditions(Column[] patterns, Column[] answers, int epochs, int offset, int length, double minerror)-
Methods inherited from class libai.nn.NeuralNetwork
error, euclideanDistance2, euclideanDistance2, gaussian, getDefaultRandomGenerator, getPlotter, getProgressBar, initializeProgressBar, open, open, open, save, setPlotter, setProgressBar, train, train
-
-
-
-
Field Detail
-
PARAM_C
public static final int PARAM_C
- See Also:
- Constant Field Values
-
PARAM_EPSILON
public static final int PARAM_EPSILON
- See Also:
- Constant Field Values
-
PARAM_TOLERANCE
public static final int PARAM_TOLERANCE
- See Also:
- Constant Field Values
-
ssign
protected static final SymmetricSign ssign
-
-
Method Detail
-
setTrainingParam
public void setTrainingParam(int param, double paramValue)
-
validatePreconditions
protected void validatePreconditions(Column[] patterns, Column[] answers, int epochs, int offset, int length, double minerror)
- Overrides:
validatePreconditionsin classSupervisedLearning
-
train
public void train(Column[] patterns, Column[] answers, double alpha, int epochs, int offset, int length, double minerror)
Description copied from class:NeuralNetworkTrains this neural network with the list ofpatternsand the expectedanswers.Use the learning rate
alphafor manyepochs. Takelengthpatterns from the positionoffsetuntil theminerroris reached.patternsandanswersmust be arrays of non-nullcolumn matrices- Specified by:
trainin classNeuralNetwork- Parameters:
patterns- The patterns to be learned.answers- The expected answers.alpha- The learning rate.epochs- The maximum number of iterationsoffset- The first pattern positionlength- How many patterns will be used.minerror- The minimal error expected.
-
simulate
public Column simulate(Column pattern)
Description copied from class:NeuralNetworkCalculates the output for thepattern.- Specified by:
simulatein classNeuralNetwork- 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:NeuralNetworkCalculates the output for thepatternand left the result inresult.- Specified by:
simulatein classNeuralNetwork- 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:NeuralNetworkCalculates the mean quadratic error. It is the standard error metric for neural networks. Just a few networks needs a different type of error metric.patternsandanswersmust be arrays of non-nullcolumn matricesNOTE: Assertions of the dimensions are made with
assertstatement. You must enable this on runtime to be effective.- Overrides:
errorin classNeuralNetwork- Parameters:
patterns- The array with the patterns to testanswers- 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.
-
-