epfl.classifier
Class VectorClassSizeAdapter

java.lang.Object
  |
  +--epfl.classifier.VectorClassSizeAdapter
All Implemented Interfaces:
VectorReader
Direct Known Subclasses:
P1VectorClassSizeAdapter, P6VectorClassSizeAdapter

public abstract class VectorClassSizeAdapter
extends java.lang.Object
implements VectorReader

A double vector class size adapter. For each read vector, the class index is decoded and put in currentClassIndex. Subclasses must implememt the classify method.


Constructor Summary
VectorClassSizeAdapter(VectorReader in, int nClasses)
          Creates a new size adapter
 
Method Summary
 void close()
          Closes the stream
 int currentClassIndex()
          Returns the current class index 0..nClasses-1
 double[] currentClassRepresentation()
          Returns the current class representation : a binary vector with a 1.0 at the current class index, and 0.0 elsewhere
 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)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorClassSizeAdapter

public VectorClassSizeAdapter(VectorReader in,
                              int nClasses)
Creates a new size adapter
Parameters:
in - the underlying vector reader
nClasses - the number of classes
The stream size is in.size() - 1
Method Detail

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

nClasses

public int nClasses()
Returns the number of classes

currentClassIndex

public int currentClassIndex()
Returns the current class index 0..nClasses-1

currentClassRepresentation

public double[] currentClassRepresentation()
Returns the current class representation : a binary vector with a 1.0 at the current class index, and 0.0 elsewhere

size

public int size()
Returns the stream size (vector size)
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

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