de.fu_berlin.ties.classify
Class ExternalClassifier

java.lang.Object
  extended byde.fu_berlin.ties.classify.TrainableClassifier
      extended byde.fu_berlin.ties.classify.ExternalClassifier
All Implemented Interfaces:
Classifier

public class ExternalClassifier
extends TrainableClassifier

A proxy that provides a trainable classifier by communicating with an external (non-Java) program. Program name and command line options of the external classifier can be configured.

Instances of this class are thread-safe if and only if several instances of the external classifier can reliably run in parallel.

Version:
$Revision: 1.13 $, $Date: 2004/04/13 08:00:13 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
static String CONFIG_DIR
          Configuration key: the directory to run the classifier in (optional, defaults to current working directory).
 
Fields inherited from interface de.fu_berlin.ties.classify.Classifier
CONFIG_CLASSIFIER
 
Constructor Summary
ExternalClassifier(Set allValidClasses)
          Creates a new instance based on the standard TIES configuration.
ExternalClassifier(Set allValidClasses, FeatureTransformer trans, File runDirectory, TiesConfiguration config)
          Creates a new instance based on the provided arguments.
ExternalClassifier(Set allValidClasses, TiesConfiguration config)
          Creates a new instance based on the provided configuration.
 
Method Summary
protected  PredictionDistribution doClassify(FeatureVector features, Set candidateClasses)
          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)
          Incorporates an item that is represented by a feature vector into the classification model.
 void init(String cls)
          Initializes a class.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class de.fu_berlin.ties.classify.TrainableClassifier
classify, createClassifier, createClassifier, createClassifier, getAllClasses, train, trainOnError, trainOnErrorHook
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONFIG_DIR

public static final String CONFIG_DIR
Configuration key: the directory to run the classifier in (optional, defaults to current working directory).

See Also:
Constant Field Values
Constructor Detail

ExternalClassifier

public ExternalClassifier(Set allValidClasses)
                   throws ProcessingException
Creates a new instance based on the standard TIES configuration.

Parameters:
allValidClasses - the set of all valid classes
Throws:
ProcessingException - if an I/O error occurs during initialization

ExternalClassifier

public ExternalClassifier(Set allValidClasses,
                          TiesConfiguration config)
                   throws ProcessingException
Creates a new instance based on the provided configuration.

Parameters:
allValidClasses - the set of all valid classes
config - contains configuration properties
Throws:
ProcessingException - if an I/O error occurs during initialization

ExternalClassifier

public ExternalClassifier(Set allValidClasses,
                          FeatureTransformer trans,
                          File runDirectory,
                          TiesConfiguration config)
                   throws ProcessingException
Creates a new instance based on the provided arguments.

Parameters:
allValidClasses - the set of all valid classes
trans - the last transformer in the transformer chain to use, or null if no feature transformers should be used
runDirectory - the directory to run the classifier in; used instead of the configured directory if not null
config - contains configuration properties
Throws:
ProcessingException - if an I/O error occurs during initialization
Method Detail

doClassify

protected PredictionDistribution doClassify(FeatureVector features,
                                            Set candidateClasses)
                                     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 array of the classes that are allowed for this item
Returns:
the result of the classification; you can call PredictionDistribution.best() to get the most probably class; this classifier returns only the best prediction, so PredictionDistribution.size() will be 1
Throws:
ProcessingException - if an I/O error occurs during communication with the external program

doTrain

protected void doTrain(FeatureVector features,
                       String targetClass)
                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
Throws:
ProcessingException - if an I/O error occurs during communication with the external program

init

public void init(String cls)
          throws ProcessingException
Initializes a class. This method is called once for each class.

Parameters:
cls - the class to initialize
Throws:
ProcessingException - if an I/O error occurs during initialization

toString

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

Overrides:
toString in class TrainableClassifier
Returns:
a textual representation


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