de.fu_berlin.ties.classify
Class MetaClassifier

java.lang.Object
  extended by de.fu_berlin.ties.classify.TrainableClassifier
      extended by de.fu_berlin.ties.classify.MetaClassifier
All Implemented Interfaces:
Classifier, XMLStorable

 class MetaClassifier
extends TrainableClassifier

A meta classifier combines several layers of classifiers. For each layer (except the last one), there is a "judge" that decides whether or not the decision of this classifier is likely to be correct. If the judge decides that it is likely to be wrong, the next layer is invoked to correct the decision.

Version:
$Revision: 1.3 $, $Date: 2004/12/09 18:09:14 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
 
Fields inherited from class de.fu_berlin.ties.classify.TrainableClassifier
META_CLASSIFIER, MULTI_CLASSIFIER, OAR_CLASSIFIER
 
Fields inherited from interface de.fu_berlin.ties.classify.Classifier
CONFIG_CLASSIFIER
 
Constructor Summary
MetaClassifier(Set<String> allValidClasses, FeatureTransformer trans, File runDirectory, String[] innerSpec, int layers, String[] judgeSpec, TiesConfiguration conf)
          Creates a new instance.
MetaClassifier(Set<String> allValidClasses, FeatureTransformer trans, File runDirectory, String[] innerSpec, TiesConfiguration conf)
          Creates a new instance.
 
Method Summary
protected  PredictionDistribution doClassify(FeatureVector features, Set candidateClasses, ContextMap context)
          Classifies an item that is represented by a feature vector by choosing the most probable class among a set of candidate classes.
protected  void doTrain(FeatureVector features, String targetClass, ContextMap context)
          Incorporates an item that is represented by a feature vector into the classification model.
 void reset()
          Resets the classifer, completely deleting the prediction model.
 String toString()
          Returns a string representation of this object.
protected  boolean trainOnErrorHook(PredictionDistribution predDist, FeatureVector features, String targetClass, Set candidateClasses, ContextMap context)
          Subclasses can implement this hook for more refined error-driven learning.
 
Methods inherited from class de.fu_berlin.ties.classify.TrainableClassifier
classify, createClassifier, createClassifier, createClassifier, createClassifier, getAllClasses, getConfig, shouldTrain, toElement, train, trainOnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaClassifier

public MetaClassifier(Set<String> allValidClasses,
                      FeatureTransformer trans,
                      File runDirectory,
                      String[] innerSpec,
                      TiesConfiguration conf)
               throws ProcessingException
Creates a new instance.

Parameters:
allValidClasses - the set of all valid classes; the first member of this set is considered as the "background" class, all further members are considered as "foreground" classes
trans - the last transformer in the transformer chain to use, or null if no feature transformers should be used
runDirectory - optional run directory passed to inner classifiers of the ExternalClassifier type
innerSpec - the specification used to initialize the inner classifiers, passed to the TrainableClassifier.createClassifier(Set, File, FeatureTransformer, String[], TiesConfiguration) factory method
conf - used to configure this instance and the inner classifiers
Throws:
ProcessingException - if an error occurred while creating this classifier or one of the wrapped classifiers

MetaClassifier

public MetaClassifier(Set<String> allValidClasses,
                      FeatureTransformer trans,
                      File runDirectory,
                      String[] innerSpec,
                      int layers,
                      String[] judgeSpec,
                      TiesConfiguration conf)
               throws ProcessingException
Creates a new instance.

Parameters:
allValidClasses - the set of all valid classes; the first member of this set is considered as the "background" class, all further members are considered as "foreground" classes
trans - the last transformer in the transformer chain to use, or null if no feature transformers should be used
runDirectory - optional run directory passed to inner classifiers of the ExternalClassifier type
innerSpec - the specification used to initialize the inner classifiers, passed to the TrainableClassifier.createClassifier(Set, File, FeatureTransformer, String[], TiesConfiguration) factory method
layers - the number of layers to use, must be at least one
judgeSpec - the specification used to initialize the judges, passed to the TrainableClassifier.createClassifier(Set, File, FeatureTransformer, String[], TiesConfiguration) factory method
conf - used to configure this instance as well as the inner classifiers and judges
Throws:
ProcessingException - if an error occurred while creating this classifier or one of the wrapped classifiers
Method Detail

doClassify

protected PredictionDistribution doClassify(FeatureVector features,
                                            Set candidateClasses,
                                            ContextMap context)
                                     throws ProcessingException
Classifies an item that is represented by a feature vector by choosing the most probable class among a set of candidate classes.

Specified by:
doClassify in class TrainableClassifier
Parameters:
features - the feature vector to consider
candidateClasses - an set of classes that are allowed for this item
context - can be used to transport implementation-specific contextual information between the TrainableClassifier.doClassify(FeatureVector, Set, ContextMap), TrainableClassifier.doTrain(FeatureVector, String, ContextMap), and TrainableClassifier.trainOnErrorHook(PredictionDistribution, FeatureVector, String, Set, ContextMap) methods
Returns:
the result of the classification; you can call PredictionDistribution.best() to get the most probably class
Throws:
ProcessingException - if an error occurs during classification

doTrain

protected void doTrain(FeatureVector features,
                       String targetClass,
                       ContextMap context)
                throws ProcessingException
Incorporates an item that is represented by a feature vector into the classification model.

Specified by:
doTrain in class TrainableClassifier
Parameters:
features - the feature vector to consider
targetClass - the class of this feature vector
context - can be used to transport implementation-specific contextual information between the TrainableClassifier.doClassify(FeatureVector, Set, ContextMap), TrainableClassifier.doTrain(FeatureVector, String, ContextMap), and TrainableClassifier.trainOnErrorHook(PredictionDistribution, FeatureVector, String, Set, ContextMap) methods
Throws:
ProcessingException - if an error occurs during training

reset

public void reset()
           throws ProcessingException
Resets the classifer, completely deleting the prediction model.

Specified by:
reset in class TrainableClassifier
Throws:
ProcessingException - if an error occurs during reset

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class TrainableClassifier
Returns:
a textual representation

trainOnErrorHook

protected boolean trainOnErrorHook(PredictionDistribution predDist,
                                   FeatureVector features,
                                   String targetClass,
                                   Set candidateClasses,
                                   ContextMap context)
                            throws ProcessingException
Subclasses can implement this hook for more refined error-driven learning. It is called from the TrainableClassifier.trainOnError(FeatureVector, String, Set) method after classifying. This method can do any necessary training itself and return true to signal that no further action is necessary. This implementation is just a placeholder that always returns false.

Overrides:
trainOnErrorHook in class TrainableClassifier
Parameters:
predDist - the prediction distribution returned by TrainableClassifier.classify(FeatureVector, Set)
features - the feature vector to consider
targetClass - the expected class of this feature vector; must be contained in the set of candidateClasses
candidateClasses - an set of classes that are allowed for this item (the actual targetClass must be one of them)
context - can be used to transport implementation-specific contextual information between the TrainableClassifier.doClassify(FeatureVector, Set, ContextMap), TrainableClassifier.doTrain(FeatureVector, String, ContextMap), and TrainableClassifier.trainOnErrorHook(PredictionDistribution, FeatureVector, String, Set, ContextMap) methods
Returns:
this implementation always returns false; subclasses can return true to signal that any error-driven learning was already handled
Throws:
ProcessingException - if an error occurs during training


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.