weka.classifiers.functions
Class SMO.BinarySMO

java.lang.Object
  extended byweka.classifiers.functions.SMO.BinarySMO
All Implemented Interfaces:
java.io.Serializable
Enclosing class:
SMO

private class SMO.BinarySMO
extends java.lang.Object
implements java.io.Serializable

Class for building a binary support vector machine.


Field Summary
private  double[] m_alpha
          The Lagrange multipliers.
private  double m_b
          The thresholds.
private  double m_bLow
          The thresholds.
private  double m_bUp
          The thresholds.
private  double[] m_class
          The transformed class values.
private  Instances m_data
          The training data.
private  double[] m_errors
          The current set of errors for all non-bound examples.
private  SMOset m_I0
          The five different sets used by the algorithm.
private  SMOset m_I1
           
private  SMOset m_I2
           
private  SMOset m_I3
           
private  SMOset m_I4
           
private  int m_iLow
          The indices for m_bLow and m_bUp
private  int m_iUp
          The indices for m_bLow and m_bUp
private  Kernel m_kernel
          Kernel to use
private  Logistic m_logistic
          Stores logistic regression model for probability estimate
private  int[] m_sparseIndices
           
private  double[] m_sparseWeights
          Variables to hold weight vector in sparse form.
private  double m_sumOfWeights
          Stores the weight of the training instances
private  SMOset m_supportVectors
          The set of support vectors
private  double[] m_weights
          Weight vector for linear machine.
 
Constructor Summary
private SMO.BinarySMO()
           
 
Method Summary
private  void buildClassifier(Instances insts, int cl1, int cl2, boolean fitLogistic, int numFolds, int randomSeed)
          Method for building the binary classifier.
private  void checkClassifier()
          Quick and dirty check whether the quadratic programming problem is solved.
private  boolean examineExample(int i2)
          Examines instance.
private  void fitLogistic(Instances insts, int cl1, int cl2, int numFolds, java.util.Random random)
          Fits logistic regression model to SVM outputs analogue to John Platt's method.
private  double SVMOutput(int index, Instance inst)
          Computes SVM output for given instance.
private  boolean takeStep(int i1, int i2, double F2)
          Method solving for the Lagrange multipliers for two instances.
 java.lang.String toString()
          Prints out the classifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_alpha

private double[] m_alpha
The Lagrange multipliers.


m_b

private double m_b
The thresholds.


m_bLow

private double m_bLow
The thresholds.


m_bUp

private double m_bUp
The thresholds.


m_iLow

private int m_iLow
The indices for m_bLow and m_bUp


m_iUp

private int m_iUp
The indices for m_bLow and m_bUp


m_data

private Instances m_data
The training data.


m_weights

private double[] m_weights
Weight vector for linear machine.


m_sparseWeights

private double[] m_sparseWeights
Variables to hold weight vector in sparse form. (To reduce storage requirements.)


m_sparseIndices

private int[] m_sparseIndices

m_kernel

private Kernel m_kernel
Kernel to use


m_class

private double[] m_class
The transformed class values.


m_errors

private double[] m_errors
The current set of errors for all non-bound examples.


m_I0

private SMOset m_I0
The five different sets used by the algorithm.


m_I1

private SMOset m_I1

m_I2

private SMOset m_I2

m_I3

private SMOset m_I3

m_I4

private SMOset m_I4

m_supportVectors

private SMOset m_supportVectors
The set of support vectors


m_logistic

private Logistic m_logistic
Stores logistic regression model for probability estimate


m_sumOfWeights

private double m_sumOfWeights
Stores the weight of the training instances

Constructor Detail

SMO.BinarySMO

private SMO.BinarySMO()
Method Detail

fitLogistic

private void fitLogistic(Instances insts,
                         int cl1,
                         int cl2,
                         int numFolds,
                         java.util.Random random)
                  throws java.lang.Exception
Fits logistic regression model to SVM outputs analogue to John Platt's method.

Parameters:
insts - the set of training instances
cl1 - the first class' index
cl2 - the second class' index
Throws:
java.lang.Exception - if the sigmoid can't be fit successfully

buildClassifier

private void buildClassifier(Instances insts,
                             int cl1,
                             int cl2,
                             boolean fitLogistic,
                             int numFolds,
                             int randomSeed)
                      throws java.lang.Exception
Method for building the binary classifier.

Parameters:
insts - the set of training instances
cl1 - the first class' index
cl2 - the second class' index
fitLogistic - true if logistic model is to be fit
numFolds - number of folds for internal cross-validation
Throws:
java.lang.Exception - if the classifier can't be built successfully

SVMOutput

private double SVMOutput(int index,
                         Instance inst)
                  throws java.lang.Exception
Computes SVM output for given instance.

Parameters:
index - the instance for which output is to be computed
inst - the instance
Returns:
the output of the SVM for the given instance
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Prints out the classifier.

Returns:
a description of the classifier as a string

examineExample

private boolean examineExample(int i2)
                        throws java.lang.Exception
Examines instance.

Parameters:
i2 - index of instance to examine
Returns:
true if examination was successfull
Throws:
java.lang.Exception - if something goes wrong

takeStep

private boolean takeStep(int i1,
                         int i2,
                         double F2)
                  throws java.lang.Exception
Method solving for the Lagrange multipliers for two instances.

Parameters:
i1 - index of the first instance
i2 - index of the second instance
Returns:
true if multipliers could be found
Throws:
java.lang.Exception - if something goes wrong

checkClassifier

private void checkClassifier()
                      throws java.lang.Exception
Quick and dirty check whether the quadratic programming problem is solved.

Throws:
java.lang.Exception