epfl.classifier
Class VectorClassSizeAdapter2

java.lang.Object
  |
  +--epfl.classifier.VectorClassSizeAdapter2
All Implemented Interfaces:
VectorReader

public class VectorClassSizeAdapter2
extends java.lang.Object
implements VectorReader

A double vector class size adapter. For each read vector, the class distribution is stored.
A vector read has two parts :
- size components which are standard components;
- the nClasses last components which are the class distribution.
This distribution is stored in the currentClassDist.
v(size components..., p(class 0), p(class 1), ..., p(class nClasses-1))


Constructor Summary
VectorClassSizeAdapter2(VectorReader in, int nClasses)
          Creates a new size adapter
 
Method Summary
 void close()
          Closes the stream
 double[] currentClassDist()
          Returns the current class distribution
 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

VectorClassSizeAdapter2

public VectorClassSizeAdapter2(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() - nClasses
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

currentClassDist

public double[] currentClassDist()
Returns the current class distribution

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