edu.cmu.minorthird.classify.algorithms.linear
Class KernelVotedPerceptron

java.lang.Object
  extended by edu.cmu.minorthird.classify.OnlineClassifierLearner
      extended by edu.cmu.minorthird.classify.OnlineBinaryClassifierLearner
          extended by edu.cmu.minorthird.classify.algorithms.linear.KernelVotedPerceptron
All Implemented Interfaces:
BinaryClassifierLearner, ClassifierLearner, java.io.Serializable, java.lang.Cloneable

public class KernelVotedPerceptron
extends OnlineBinaryClassifierLearner
implements java.io.Serializable

Voted perceptron algorithm. As described in "Large Margin Classification Using the Perceptron Algorithm", Yoav Freund and Robert E. Schapire, Proceedings of the Eleventh Annual Conference on Computational Learning Theory, 1998. Polynomial kernel is implemented: K(x,y) = (coef0+gamma*)^d Both "voted" and "averaged" modes are implemented (unnormalized). Poly degree = 0 means that no kernel is used. Therefore, mode "averaged" with degree=0 should be equivalent to results in VotedPerceptron.java (file with a faster implementation of the averaged nonnormalized perceptron)

Author:
Vitor Carvalho
See Also:
Serialized Form

Nested Class Summary
 class KernelVotedPerceptron.MyClassifier
           
 
Constructor Summary
KernelVotedPerceptron()
          Default Constructor: degree=3 and mode="voted"
KernelVotedPerceptron(int degree, java.lang.String mode)
          Constructor: specifies degree of poly kernel and mode Example KernelVotedPerceptron(3,"averaged") or (5,"voted")
 
Method Summary
 void addExample(Example example)
          Subclasses should use this method to perform whatever incremental update is needed after in response to a new example.
 Classifier getClassifier()
          Subclasses should use this method to return the current classifier.
 void reset()
          'forget' everything about the last learning task, and start a new task.
 void setKernel(int d)
          set degree of poly kernel K(x,y) = (coef0+ gamma*)^d if set to 0, usual crossproduct is used.
 void setModeAveraged()
           
 void setModeVoted()
           
 void setPolyKernelParams(double coef0, double gamma)
          set params of poly kernel K(x,y) = (coef0+ gamma*)^d
 void setSpeedUp()
          Set speed-up: use only last 300 support vectors in testing
 java.lang.String toString()
           
 
Methods inherited from class edu.cmu.minorthird.classify.OnlineBinaryClassifierLearner
getBinaryClassifier, getSchema, setSchema
 
Methods inherited from class edu.cmu.minorthird.classify.OnlineClassifierLearner
completeTraining, copy, hasNextQuery, nextQuery, setInstancePool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.cmu.minorthird.classify.ClassifierLearner
completeTraining, copy, hasNextQuery, nextQuery, setInstancePool
 

Constructor Detail

KernelVotedPerceptron

public KernelVotedPerceptron(int degree,
                             java.lang.String mode)
Constructor: specifies degree of poly kernel and mode Example KernelVotedPerceptron(3,"averaged") or (5,"voted")

Parameters:
degree -
mode -

KernelVotedPerceptron

public KernelVotedPerceptron()
Default Constructor: degree=3 and mode="voted"

Method Detail

setKernel

public void setKernel(int d)
set degree of poly kernel K(x,y) = (coef0+ gamma*)^d if set to 0, usual crossproduct is used.

Parameters:
d -

setPolyKernelParams

public void setPolyKernelParams(double coef0,
                                double gamma)
set params of poly kernel K(x,y) = (coef0+ gamma*)^d

Parameters:
coef0 -
gamma -

reset

public void reset()
Description copied from class: OnlineClassifierLearner
'forget' everything about the last learning task, and start a new task. Subclasses need to implement this method

Specified by:
reset in interface ClassifierLearner
Specified by:
reset in class OnlineClassifierLearner

setModeVoted

public void setModeVoted()

setModeAveraged

public void setModeAveraged()

setSpeedUp

public void setSpeedUp()
Set speed-up: use only last 300 support vectors in testing


addExample

public void addExample(Example example)
Description copied from class: OnlineClassifierLearner
Subclasses should use this method to perform whatever incremental update is needed after in response to a new example.

Specified by:
addExample in interface ClassifierLearner
Specified by:
addExample in class OnlineClassifierLearner

getClassifier

public Classifier getClassifier()
Description copied from class: OnlineClassifierLearner
Subclasses should use this method to return the current classifier.

Specified by:
getClassifier in interface ClassifierLearner
Specified by:
getClassifier in class OnlineClassifierLearner

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object