epfl.classifier
Class AbstractClassifier

java.lang.Object
  |
  +--epfl.classifier.AbstractClassifier
All Implemented Interfaces:
Classifier, VectorReader
Direct Known Subclasses:
MixtureModelClassifier, MultMixtureModelClassifier

public abstract class AbstractClassifier
extends java.lang.Object
implements Classifier

The root class for all classifiers. Subclasses must override the classification function.


Constructor Summary
AbstractClassifier()
          Creates a new classifier without stream connection
AbstractClassifier(VectorReader in)
          Creates a new classifier
 
Method Summary
abstract  double[] classify(double[] features)
          Classification function
 void close()
          Closes the stream
abstract  int nClasses()
          Returns the number of classes
 int period()
          Returns the stream period
 double[] read()
          Reads a vector in stream
 int size()
          Returns the stream size (vector size), same as nClasses
 void tagWrite(TagWriter out)
          Writes a tag representation for this classifier in a tag writer
abstract  void tagWrite(TagWriter out, TagWriter.Indent _indent)
          Writes a tag representation for this classifier in a tag writer
 java.lang.String toString()
          Returns a string representation for this classifier
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractClassifier

public AbstractClassifier(VectorReader in)
Creates a new classifier
Parameters:
in - the underlying vector reader

AbstractClassifier

public AbstractClassifier()
Creates a new classifier without stream connection
Method Detail

classify

public abstract double[] classify(double[] features)
Classification function
Specified by:
classify in interface Classifier

read

public double[] read()
              throws java.io.IOException
Reads a vector in stream
Specified by:
read in interface VectorReader
Throws:
java.io.IOException - if the stream is closed or if it is unable to read size doubles

size

public int size()
Returns the stream size (vector size), same as nClasses
Specified by:
size in interface VectorReader

period

public int period()
Returns the stream period
Specified by:
period in interface VectorReader
Returns:
0 if the stream is not periodic

nClasses

public abstract int nClasses()
Returns the number of classes
Specified by:
nClasses in interface Classifier

close

public void close()
           throws java.io.IOException
Closes the stream
Specified by:
close in interface VectorReader
Throws:
java.io.IOException - an IO error occurs

toString

public java.lang.String toString()
Returns a string representation for this classifier
Overrides:
toString in class java.lang.Object

tagWrite

public abstract void tagWrite(TagWriter out,
                              TagWriter.Indent _indent)
Writes a tag representation for this classifier in a tag writer

tagWrite

public void tagWrite(TagWriter out)
Writes a tag representation for this classifier in a tag writer