SciLib.Neuro.SVM
Class BSVM

java.lang.Object
  extended by SciLib.Neuro.SVM.SVM
      extended by SciLib.Neuro.SVM.BSVM
All Implemented Interfaces:
SMO

public class BSVM
extends SVM
implements SMO


Field Summary
protected  int c1
           
protected  int c2
           
 
Fields inherited from class SciLib.Neuro.SVM.SVM
alpha, B, b_low, b_up, binary, C, eps, error_cache, file, GACV1, i_low, i_up, JHB, K, M, N, patterns, sparse, sv, svIndex, targets, tolerance
 
Constructor Summary
BSVM(FileHandler file, boolean transf, int c1)
          Constructor
BSVM(FileHandler file, Kernel K, boolean transf, int c1)
          Constructor
BSVM(matrix patterns, integerVector targets, Kernel K)
          Constructor
BSVM(matrix patterns, integerVector targets, Kernel K, boolean transf, int c1)
          Constructor
BSVM(matrix patterns, integerVector targets, Kernel K, int c1, int c2)
          Constructor
 
Method Summary
 void crossValidation(int k, double startLog2C, int cs, double startLambda, int ls, double a, double b)
          cross-validation
 void doneTransf()
           
 boolean doneTransform()
           
 int getC1()
           
 int getC2()
           
 void LOOValidation(int type, double[] cPar, double[] lambdaPar, double a, double b)
           
 void LOOValidation(int type, double startLog2C, int cs, double startLambda, int ls, double a, double b)
          Leave-one-out-validation
 int misclassified(matrix p, integerVector t)
           
 double testing(FileHandler testFile)
          test svm without scaling method
 double testing(FileHandler testFile, double a, double b)
          test svm with scaling method
 double testing(FileHandler testFile, java.lang.String alphaFile)
          test svm without scaling method
 double testing(FileHandler testFile, java.lang.String alphaFile, double a, double b)
          test svm with scaling method
 void training(java.lang.String alphaFile)
          the training algorithm with no cross validation and no scaling
 void training(java.lang.String alphaFile, double a, double b)
          training svm with the data scaled between a, b ( a < b )
 
Methods inherited from class SciLib.Neuro.SVM.SVM
computeB, f, f, getAlpha, getB, getC, getEpsi, getFile, getKernel, getNoOfSV, getPatterns, getSV, getSVIndex, getTargets, getTolerance, initialize, initiateParameter, isBinary, isInI0I1I2, isInI0I3I4, isInI1I2, isInI3I4, isSparse, makeTargets, readSVs, setB, setC, setEpsi, setFile, setKernel, setN, setTolerance, writeReport, writeResultToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c1

protected int c1

c2

protected int c2
Constructor Detail

BSVM

public BSVM(FileHandler file,
            Kernel K,
            boolean transf,
            int c1)
Constructor

Parameters:
file - the file that handles training data, FileHandler
K - the kernel of SVM, Kernel
transf - convert the target data to the form of 1 and -1, boolean
c1 - will be convert to 1, int

BSVM

public BSVM(FileHandler file,
            boolean transf,
            int c1)
Constructor

Parameters:
file - the file that handles training data, FileHandler
transf - convert the target data to the form of 1 and -1, boolean
c1 - will be convert to 1, int

BSVM

public BSVM(matrix patterns,
            integerVector targets,
            Kernel K,
            boolean transf,
            int c1)
Constructor

Parameters:
patterns - the training data, matrix
targets - labels of the training data, integerVector
K - the kernel of SVM, Kernel
transf - convert the target data to the form of 1 and -1, boolean
c1 - will be convert to 1, int

BSVM

public BSVM(matrix patterns,
            integerVector targets,
            Kernel K,
            int c1,
            int c2)
Constructor

Parameters:
patterns - the training data, matrix
targets - labels of the training data, integerVector
K - the kernel of SVM, Kernel
c1 - will be convert to 1, int
c2 - will be convert to -1, int

BSVM

public BSVM(matrix patterns,
            integerVector targets,
            Kernel K)
Constructor

Parameters:
patterns - the training data, matrix
targets - labels of the training data, integerVector
K - the kernel of SVM, Kernel
Method Detail

doneTransform

public boolean doneTransform()

doneTransf

public void doneTransf()

getC1

public int getC1()

getC2

public int getC2()

training

public void training(java.lang.String alphaFile)
the training algorithm with no cross validation and no scaling

Specified by:
training in interface SMO
Overrides:
training in class SVM
Parameters:
alphaFile - fileName for store the support vectors

training

public void training(java.lang.String alphaFile,
                     double a,
                     double b)
training svm with the data scaled between a, b ( a < b )

Specified by:
training in interface SMO
Overrides:
training in class SVM
Parameters:
alphaFile - fileName for store the support vectors
a - the lower bound of scaled data
b - the upper bound of scaled data

crossValidation

public void crossValidation(int k,
                            double startLog2C,
                            int cs,
                            double startLambda,
                            int ls,
                            double a,
                            double b)
cross-validation

Specified by:
crossValidation in interface SMO
Overrides:
crossValidation in class SVM
Parameters:
k - k-fold cross validation k > 1
startLog2C - log2 of the start value of C, double
cs - the size of the set that contains all C, int
startLambda - log2 of the start value of lambda, double
ls - the size of the set that contains all lambdas, int
a - the lower bound of scaled data
b - the upper bound of scaled data

misclassified

public int misclassified(matrix p,
                         integerVector t)
Specified by:
misclassified in interface SMO
Overrides:
misclassified in class SVM

testing

public double testing(FileHandler testFile)
test svm without scaling method

Specified by:
testing in interface SMO
Overrides:
testing in class SVM
Parameters:
testFile - FileHandler handles the test file data

testing

public double testing(FileHandler testFile,
                      double a,
                      double b)
test svm with scaling method

Specified by:
testing in interface SMO
Overrides:
testing in class SVM
Parameters:
testFile - FileHandler handles the test file data
a - the lower bound of scaled data
b - the upper bound of scaled data

testing

public double testing(FileHandler testFile,
                      java.lang.String alphaFile)
test svm without scaling method

Specified by:
testing in interface SMO
Overrides:
testing in class SVM
Parameters:
testFile - FileHandler handles the test file data
alphaFile - the file name of the file that stores support vectors

testing

public double testing(FileHandler testFile,
                      java.lang.String alphaFile,
                      double a,
                      double b)
test svm with scaling method

Specified by:
testing in interface SMO
Overrides:
testing in class SVM
Parameters:
testFile - FileHandler handles the test file data
alphaFile - the file name of the file that stores support vectors
a - the lower bound of scaled data
b - the upper bound of scaled data

LOOValidation

public void LOOValidation(int type,
                          double startLog2C,
                          int cs,
                          double startLambda,
                          int ls,
                          double a,
                          double b)
Leave-one-out-validation

Specified by:
LOOValidation in interface SMO
Overrides:
LOOValidation in class SVM
Parameters:
type - method of LOO validation, constant JHB, GACV1. etc.
startLog2C - log2 of the start value of C, double
cs - the size of the set that contains all C, int
startLambda - log2 of the start value of lambda, double
ls - the size of the set that contains all lambdas, int
a - the lower bound of scaled data
b - the upper bound of scaled data

LOOValidation

public void LOOValidation(int type,
                          double[] cPar,
                          double[] lambdaPar,
                          double a,
                          double b)
Specified by:
LOOValidation in interface SMO
Overrides:
LOOValidation in class SVM