public class SMO.BinarySMO
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected double[] |
m_alpha
The Lagrange multipliers.
|
protected double |
m_b
The thresholds.
|
protected double |
m_bLow
The thresholds.
|
protected double |
m_bUp
The thresholds.
|
protected double[] |
m_class
The transformed class values.
|
protected Instances |
m_data
The training data.
|
protected double[] |
m_errors
The current set of errors for all non-bound examples.
|
protected SMOset |
m_I0
{i: 0 < m_alpha[i] < C}
|
protected SMOset |
m_I1
{i: m_class[i] = 1, m_alpha[i] = 0}
|
protected SMOset |
m_I2
{i: m_class[i] = -1, m_alpha[i] =C}
|
protected SMOset |
m_I3
{i: m_class[i] = 1, m_alpha[i] = C}
|
protected SMOset |
m_I4
{i: m_class[i] = -1, m_alpha[i] = 0}
|
protected int |
m_iLow
The indices for m_bLow and m_bUp
|
protected int |
m_iUp
The indices for m_bLow and m_bUp
|
protected Kernel |
m_kernel
Kernel to use
|
protected Logistic |
m_logistic
Stores logistic regression model for probability estimate
|
protected int[] |
m_sparseIndices
Variables to hold indices vector in sparse form.
|
protected double[] |
m_sparseWeights
Variables to hold weight vector in sparse form.
|
protected double |
m_sumOfWeights
Stores the weight of the training instances
|
protected SMOset |
m_supportVectors
The set of support vectors
|
protected double[] |
m_weights
Weight vector for linear machine.
|
Constructor and Description |
---|
BinarySMO() |
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances insts,
int cl1,
int cl2,
boolean fitLogistic,
int numFolds,
int randomSeed)
Method for building the binary classifier.
|
protected void |
checkClassifier()
Quick and dirty check whether the quadratic programming problem is solved.
|
protected boolean |
examineExample(int i2)
Examines instance.
|
protected 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.
|
double |
getB()
This method returns the 'b' threshold value of this SMO
|
double[] |
getClasses()
This method returns the transformed class values of each instance
|
Kernel |
getKernel()
Returns the kernel to use
|
double[] |
getLagrangeMultipliers()
This method returns the Lagrange Multipliers obtained for each instance.
|
SMOset |
getSupportVectors()
This method returns the support vectors
|
void |
setKernel(Kernel value)
sets the kernel to use
|
double |
SVMOutput(int index,
Instance inst)
Computes SVM output for given instance.
|
protected boolean |
takeStep(int i1,
int i2,
double F2)
Method solving for the Lagrange multipliers for
two instances.
|
protected double[] m_alpha
protected double m_b
protected double m_bLow
protected double m_bUp
protected int m_iLow
protected int m_iUp
protected Instances m_data
protected double[] m_weights
protected double[] m_sparseWeights
protected int[] m_sparseIndices
protected Kernel m_kernel
protected double[] m_class
protected double[] m_errors
protected SMOset m_I0
protected SMOset m_I1
protected SMOset m_I2
protected SMOset m_I3
protected SMOset m_I4
protected SMOset m_supportVectors
protected Logistic m_logistic
protected double m_sumOfWeights
protected void fitLogistic(Instances insts, int cl1, int cl2, int numFolds, java.util.Random random) throws java.lang.Exception
insts
- the set of training instancescl1
- the first class' indexcl2
- the second class' indexnumFolds
- the number of folds for cross-validationrandom
- for randomizing the datajava.lang.Exception
- if the sigmoid can't be fit successfullypublic void setKernel(Kernel value)
value
- the kernel to usepublic Kernel getKernel()
public void buildClassifier(Instances insts, int cl1, int cl2, boolean fitLogistic, int numFolds, int randomSeed) throws java.lang.Exception
insts
- the set of training instancescl1
- the first class' indexcl2
- the second class' indexfitLogistic
- true if logistic model is to be fitnumFolds
- number of folds for internal cross-validationrandomSeed
- random number generator for cross-validationjava.lang.Exception
- if the classifier can't be built successfullypublic double SVMOutput(int index, Instance inst) throws java.lang.Exception
index
- the instance for which output is to be computedinst
- the instancejava.lang.Exception
- in case of an errorprotected boolean examineExample(int i2) throws java.lang.Exception
i2
- index of instance to examinejava.lang.Exception
- if something goes wrongprotected boolean takeStep(int i1, int i2, double F2) throws java.lang.Exception
i1
- index of the first instancei2
- index of the second instanceF2
- java.lang.Exception
- if something goes wrongprotected void checkClassifier() throws java.lang.Exception
java.lang.Exception
- if checking failspublic double getB()
public SMOset getSupportVectors()
public double[] getLagrangeMultipliers()
public double[] getClasses()