se.lth.cs.nlp.nlputils.ml
Class Classifier<ItemType>

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.ml.Classifier<ItemType>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BinaryNumericClassifier, ClasswiseClassifier, PairwiseClassifier, ProbabilityClassifier

public abstract class Classifier<ItemType>
extends Object
implements Serializable

Abstract class representing a classifier.

Author:
Richard Johansson (richard@cs.lth.se)
See Also:
Serialized Form

Field Summary
protected  FeatureExtractor<ItemType> extractor
          The feature extractor that is used in classify(ItemType item).
protected  FeatureList list
          The feature list that is used in classify(ItemType item).
 
Constructor Summary
Classifier()
           
 
Method Summary
abstract  Object classify(FeatureList features)
          Performs a classification given a feature list.
 Object classify(ItemType item)
          Auxiliary method that calls the feature extractor on the item.
 Object classifyRestricted(FeatureList features, Collection classes)
          Optional method that makes sure that restricts the range of the output value.
 void setFeatureExtractor(FeatureExtractor<ItemType> extractor, FeatureList list)
          Sets the feature extractor of this classifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extractor

protected FeatureExtractor<ItemType> extractor
The feature extractor that is used in classify(ItemType item).


list

protected FeatureList list
The feature list that is used in classify(ItemType item).

Constructor Detail

Classifier

public Classifier()
Method Detail

classify

public Object classify(ItemType item)
Auxiliary method that calls the feature extractor on the item.

Parameters:
item - the item to classify.
Returns:
the result of the classification, or null if the feature extraction did not return FEATURE_EXTRACTOR_OK.

classify

public abstract Object classify(FeatureList features)
Performs a classification given a feature list.

Parameters:
features - the feature list.
Returns:
the result of the classification.

setFeatureExtractor

public void setFeatureExtractor(FeatureExtractor<ItemType> extractor,
                                FeatureList list)
Sets the feature extractor of this classifier.

Parameters:
extractor - the feature extractor.

classifyRestricted

public Object classifyRestricted(FeatureList features,
                                 Collection classes)
Optional method that makes sure that restricts the range of the output value.

Parameters:
features - the feature list.
classes - a collection of allowed classes.
Returns:
the result of the classification.
Throws:
UnsupportedOperationException - if the method is not implemented.