Package cc.mallet.classify
Class WinnowTrainer
- java.lang.Object
-
- cc.mallet.classify.ClassifierTrainer<Winnow>
-
- cc.mallet.classify.WinnowTrainer
-
public class WinnowTrainer extends ClassifierTrainer<Winnow>
An implementation of the training methods of a Winnow2 on-line classifier. Given an instance xi, the algorithm computes Sum(xi*wi), where wi is the weight for that feature in the given class. If the Sum is greater than some thresholdtheta, then the classifier guess true for that class. Only when the classifier makes a mistake are the weights updated in one of two steps: Promote: guessed 0 and answer was 1. Multiply all weights of present features byalpha. Demote: guessed 1 and answer was 0. Divide all weights of present features bybeta. Limitations: Winnow2 only considers binary feature vectors (i.e. whether or not the feature is present, not its value).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cc.mallet.classify.ClassifierTrainer
ClassifierTrainer.ByActiveLearning<C extends Classifier>, ClassifierTrainer.ByIncrements<C extends Classifier>, ClassifierTrainer.ByInstanceIncrements<C extends Classifier>, ClassifierTrainer.ByOptimization<C extends Classifier>, ClassifierTrainer.Factory<CT extends ClassifierTrainer<? extends Classifier>>
-
-
Field Summary
-
Fields inherited from class cc.mallet.classify.ClassifierTrainer
finishedTraining, validationSet
-
-
Constructor Summary
Constructors Constructor Description WinnowTrainer()Default constructor.WinnowTrainer(double a, double b)Sets alpha and beta and default value for thetaWinnowTrainer(double a, double b, double nfact)Sets alpha, beta, and nfactor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WinnowgetClassifier()Winnowtrain(InstanceList trainingList)Trains winnow on the instance list, updatingweightsaccording to errors-
Methods inherited from class cc.mallet.classify.ClassifierTrainer
getValidationInstances, isFinishedTraining, setValidationInstances
-
-
-
-
Constructor Detail
-
WinnowTrainer
public WinnowTrainer()
Default constructor. Sets all features to defaults.
-
WinnowTrainer
public WinnowTrainer(double a, double b)Sets alpha and beta and default value for theta- Parameters:
a- alpha valueb- beta value
-
WinnowTrainer
public WinnowTrainer(double a, double b, double nfact)Sets alpha, beta, and nfactor- Parameters:
a- alpha valueb- beta valuenfact- nfactor value
-
-
Method Detail
-
getClassifier
public Winnow getClassifier()
- Specified by:
getClassifierin classClassifierTrainer<Winnow>
-
train
public Winnow train(InstanceList trainingList)
Trains winnow on the instance list, updatingweightsaccording to errors- Specified by:
trainin classClassifierTrainer<Winnow>- Parameters:
ilist- Instance list to be trained on- Returns:
- Classifier object containing learned weights
-
-