weka.classifiers.functions
Class Winnow

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.functions.Winnow
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable, UpdateableClassifier

public class Winnow
extends Classifier
implements UpdateableClassifier

Implements Winnow and Balanced Winnow algorithms by N. Littlestone. For more information, see

N. Littlestone (1988). Learning quickly when irrelevant attributes are abound: A new linear threshold algorithm. Machine Learning 2, pp. 285-318.

and N. Littlestone (1989). Mistake bounds and logarithmic linear-threshold learning algorithms. Technical report UCSC-CRL-89-11, University of California, Santa Cruz.

Valid options are:

-L
Use the baLanced variant (default: false)

-I num
The number of iterations to be performed. (default 1)

-A double
Promotion coefficient alpha. (default 2.0)

-B double
Demotion coefficient beta. (default 0.5)

-W double
Starting weights of the prediction coeffs. (default 2.0)

-H double
Prediction threshold. (default -1.0 == number of attributes)

-S int
Random seed to shuffle the input. (default 1), -1 == no shuffling

Version:
$Revision: 1.7 $
Author:
J. Lindgren (jtlindgrcs.helsinki.fi)
See Also:
Serialized Form

Field Summary
private  double m_actualThreshold
          The true threshold used for prediction
protected  double m_Alpha
          The promotion coefficient
protected  boolean m_Balanced
          Use the balanced variant?
protected  double m_Beta
          The demotion coefficient
protected  double m_defaultWeight
          Starting weights for the prediction vector(s)
protected  int m_Mistakes
          Accumulated mistake count (for statistics)
private  NominalToBinary m_NominalToBinary
          The filter used to make attributes numeric.
protected  int m_numIterations
          The number of iterations
private  double[] m_predNegVector
           
private  double[] m_predPosVector
          The weight vectors for prediction
private  ReplaceMissingValues m_ReplaceMissingValues
          The filter used to get rid of missing values.
protected  int m_Seed
          Random seed used for shuffling the dataset, -1 == disable
protected  double m_Threshold
          Prediction threshold, <0 == numAttributes
private  Instances m_Train
          The training instances
 
Fields inherited from class weka.classifiers.Classifier
m_Debug
 
Constructor Summary
Winnow()
           
 
Method Summary
private  void actualUpdateClassifier(Instance inst)
          Actual update routine for prefiltered instances
private  void actualUpdateClassifierBalanced(Instance inst)
          Actual update routine (balanced) for prefiltered instances
 java.lang.String alphaTipText()
          Returns the tip text for this property
 java.lang.String balancedTipText()
          Returns the tip text for this property
 java.lang.String betaTipText()
          Returns the tip text for this property
 void buildClassifier(Instances insts)
          Builds the classifier
 double classifyInstance(Instance inst)
          Outputs the prediction for the given instance.
 java.lang.String defaultWeightTipText()
          Returns the tip text for this property
 double getAlpha()
          Get the value of Alpha.
 boolean getBalanced()
          Get the value of Balanced.
 double getBeta()
          Get the value of Beta.
 double getDefaultWeight()
          Get the value of defaultWeight.
 int getNumIterations()
          Get the value of numIterations.
 java.lang.String[] getOptions()
          Gets the current settings of the classifier.
 int getSeed()
          Get the value of Seed.
 double getThreshold()
          Get the value of Threshold.
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(java.lang.String[] argv)
          Main method.
private  double makePrediction(Instance inst)
          Compute the actual prediction for prefiltered instance
private  double makePredictionBalanced(Instance inst)
          Compute our prediction (Balanced) for prefiltered instance
 java.lang.String numIterationsTipText()
          Returns the tip text for this property
 java.lang.String seedTipText()
          Returns the tip text for this property
 void setAlpha(double a)
          Set the value of Alpha.
 void setBalanced(boolean b)
          Set the value of Balanced.
 void setBeta(double b)
          Set the value of Beta.
 void setDefaultWeight(double w)
          Set the value of defaultWeight.
 void setNumIterations(int v)
          Set the value of numIterations.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSeed(int v)
          Set the value of Seed.
 void setThreshold(double t)
          Set the value of Threshold.
 java.lang.String thresholdTipText()
          Returns the tip text for this property
 java.lang.String toString()
          Returns textual description of the classifier.
 void updateClassifier(Instance instance)
          Updates the classifier with a new learning example
 
Methods inherited from class weka.classifiers.Classifier
debugTipText, distributionForInstance, forName, getDebug, makeCopies, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Balanced

protected boolean m_Balanced
Use the balanced variant?


m_numIterations

protected int m_numIterations
The number of iterations


m_Alpha

protected double m_Alpha
The promotion coefficient


m_Beta

protected double m_Beta
The demotion coefficient


m_Threshold

protected double m_Threshold
Prediction threshold, <0 == numAttributes


m_Seed

protected int m_Seed
Random seed used for shuffling the dataset, -1 == disable


m_Mistakes

protected int m_Mistakes
Accumulated mistake count (for statistics)


m_defaultWeight

protected double m_defaultWeight
Starting weights for the prediction vector(s)


m_predPosVector

private double[] m_predPosVector
The weight vectors for prediction


m_predNegVector

private double[] m_predNegVector

m_actualThreshold

private double m_actualThreshold
The true threshold used for prediction


m_Train

private Instances m_Train
The training instances


m_NominalToBinary

private NominalToBinary m_NominalToBinary
The filter used to make attributes numeric.


m_ReplaceMissingValues

private ReplaceMissingValues m_ReplaceMissingValues
The filter used to get rid of missing values.

Constructor Detail

Winnow

public Winnow()
Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options

Specified by:
listOptions in interface OptionHandler
Overrides:
listOptions in class Classifier
Returns:
an enumeration of all the available options

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class Classifier
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the classifier.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class Classifier
Returns:
an array of strings suitable for passing to setOptions

buildClassifier

public void buildClassifier(Instances insts)
                     throws java.lang.Exception
Builds the classifier

Specified by:
buildClassifier in class Classifier
Parameters:
insts - set of instances serving as training data
Throws:
java.lang.Exception - if something goes wrong during building

updateClassifier

public void updateClassifier(Instance instance)
                      throws java.lang.Exception
Updates the classifier with a new learning example

Specified by:
updateClassifier in interface UpdateableClassifier
Parameters:
instance - the instance to included
Throws:
java.lang.Exception - if something goes wrong

actualUpdateClassifier

private void actualUpdateClassifier(Instance inst)
                             throws java.lang.Exception
Actual update routine for prefiltered instances

Throws:
java.lang.Exception - if something goes wrong

actualUpdateClassifierBalanced

private void actualUpdateClassifierBalanced(Instance inst)
                                     throws java.lang.Exception
Actual update routine (balanced) for prefiltered instances

Throws:
java.lang.Exception - if something goes wrong

classifyInstance

public double classifyInstance(Instance inst)
                        throws java.lang.Exception
Outputs the prediction for the given instance.

Overrides:
classifyInstance in class Classifier
Parameters:
inst - the instance for which prediction is to be computed
Returns:
the prediction
Throws:
java.lang.Exception - if something goes wrong

makePrediction

private double makePrediction(Instance inst)
                       throws java.lang.Exception
Compute the actual prediction for prefiltered instance

Parameters:
inst - the instance for which prediction is to be computed
Returns:
the prediction
Throws:
java.lang.Exception - if something goes wrong

makePredictionBalanced

private double makePredictionBalanced(Instance inst)
                               throws java.lang.Exception
Compute our prediction (Balanced) for prefiltered instance

Parameters:
inst - the instance for which prediction is to be computed
Returns:
the prediction
Throws:
java.lang.Exception - if something goes wrong

toString

public java.lang.String toString()
Returns textual description of the classifier.


balancedTipText

public java.lang.String balancedTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getBalanced

public boolean getBalanced()
Get the value of Balanced.

Returns:
Value of Balanced.

setBalanced

public void setBalanced(boolean b)
Set the value of Balanced.

Parameters:
b - Value to assign to Balanced.

alphaTipText

public java.lang.String alphaTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getAlpha

public double getAlpha()
Get the value of Alpha.

Returns:
Value of Alpha.

setAlpha

public void setAlpha(double a)
Set the value of Alpha.

Parameters:
a - Value to assign to Alpha.

betaTipText

public java.lang.String betaTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getBeta

public double getBeta()
Get the value of Beta.

Returns:
Value of Beta.

setBeta

public void setBeta(double b)
Set the value of Beta.

Parameters:
b - Value to assign to Beta.

thresholdTipText

public java.lang.String thresholdTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getThreshold

public double getThreshold()
Get the value of Threshold.

Returns:
Value of Threshold.

setThreshold

public void setThreshold(double t)
Set the value of Threshold.

Parameters:
t - Value to assign to Threshold.

defaultWeightTipText

public java.lang.String defaultWeightTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getDefaultWeight

public double getDefaultWeight()
Get the value of defaultWeight.

Returns:
Value of defaultWeight.

setDefaultWeight

public void setDefaultWeight(double w)
Set the value of defaultWeight.

Parameters:
w - Value to assign to defaultWeight.

numIterationsTipText

public java.lang.String numIterationsTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getNumIterations

public int getNumIterations()
Get the value of numIterations.

Returns:
Value of numIterations.

setNumIterations

public void setNumIterations(int v)
Set the value of numIterations.

Parameters:
v - Value to assign to numIterations.

seedTipText

public java.lang.String seedTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getSeed

public int getSeed()
Get the value of Seed.

Returns:
Value of Seed.

setSeed

public void setSeed(int v)
Set the value of Seed.

Parameters:
v - Value to assign to Seed.

main

public static void main(java.lang.String[] argv)
Main method.