marf.Storage
Class TrainingSample

java.lang.Object
  extended by marf.Storage.TrainingSample
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ITrainingSample
Direct Known Subclasses:
Cluster

public class TrainingSample
extends java.lang.Object
implements ITrainingSample

TrainingSample contains one item in the training set. Each training sample consists of the feature vector plus information describing that feature vector. Has been extracted from TrainingSet in 0.3.0. TODO: fix CSV dumps.

$Id: TrainingSample.java,v 1.15 2008/02/20 07:29:06 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.15 $
Author:
Stephen Sinclair, Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  double[] adDataVector
          Array representing either a feature vector, mean vector describing the cluster, or a median vector.
protected  int iSubjectID
          Which subject this feature vector is associated with.
protected  java.util.Vector oFilenames
          A list of filenames that were used in training for this sample.
private static long serialVersionUID
          For serialization versioning.
 
Constructor Summary
TrainingSample()
          Default training sample constructor.
TrainingSample(TrainingSample poTrainingSample)
          Copy-constructor.
 
Method Summary
 boolean addFeatureVector(double[] padFeatureVector, java.lang.String pstrFilename, int piSubjectID)
          Fully equivalent to setFeatureVector().
 boolean addFilename(java.lang.String pstrFilename)
          Adds a filename to the training sample.
 java.lang.Object clone()
          Implements Cloneable interface for the TrainingSample object.
 void dumpCSV(java.io.BufferedWriter poBufferedWriter)
          Writes one training sample to a CSV file.
 boolean existsFilename(java.lang.String pstrFilename)
          Checks existence of the file in the training sample.
 double[] getDataVector()
          Retrieves the data vector.
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 int getMeanCount()
          Retrieves current mean count.
 double[] getMeanVector()
          Simply retrieves the data vector.
 double[] getMedianVector()
          Simply retrieves the data vector.
 int getSubjectID()
          Retrieves Subject ID of a particular training sample.
 void restoreCSV(java.io.BufferedReader poBufferedReader)
          Retrieve one training sample from a CSV file.
 void setDataVector(double[] padDataVector)
          Sets new mean vector.
 boolean setFeatureVector(double[] padFeatureVector, java.lang.String pstrFilename, int piSubjectID)
           
 void setFilename(java.lang.String pstrFilename)
          Sets a filename of the training sample.
 void setSubjectID(int piSubjectID)
          Sets new Subject ID.
 int size()
           
 java.lang.String toString()
          Provides string representation of the training sample data.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iSubjectID

protected int iSubjectID
Which subject this feature vector is associated with. This is an application-independent ID within MARF to distinguish from other subjects. Typical subjects may include speakers, languages instruments, emotions, etc. that a give application is taken care of.


adDataVector

protected double[] adDataVector
Array representing either a feature vector, mean vector describing the cluster, or a median vector.


oFilenames

protected java.util.Vector oFilenames
A list of filenames that were used in training for this sample. Used to avoid duplicate training on the same filename.


serialVersionUID

private static final long serialVersionUID
For serialization versioning. When adding new members or make other structural changes regenerate this number with the serialver tool that comes with JDK.

Since:
0.3.0.4
See Also:
Constant Field Values
Constructor Detail

TrainingSample

public TrainingSample()
Default training sample constructor. Explicitly appeared in 0.3.0.5.

Since:
0.3.0.5

TrainingSample

public TrainingSample(TrainingSample poTrainingSample)
Copy-constructor.

Parameters:
poTrainingSample - TrainingSample object to copy
Since:
0.3.0.5
Method Detail

setFeatureVector

public boolean setFeatureVector(double[] padFeatureVector,
                                java.lang.String pstrFilename,
                                int piSubjectID)
Specified by:
setFeatureVector in interface ITrainingSample
Returns:

addFeatureVector

public boolean addFeatureVector(double[] padFeatureVector,
                                java.lang.String pstrFilename,
                                int piSubjectID)
Description copied from interface: ITrainingSample
Fully equivalent to setFeatureVector().

Specified by:
addFeatureVector in interface ITrainingSample
Returns:
See Also:
ITrainingSample.setFeatureVector(double[], String, int)

setFilename

public void setFilename(java.lang.String pstrFilename)
Description copied from interface: ITrainingSample
Sets a filename of the training sample. Always set the first element of the list of filenames.

Specified by:
setFilename in interface ITrainingSample
Parameters:
pstrFilename - filename to set

addFilename

public boolean addFilename(java.lang.String pstrFilename)
Adds a filename to the training sample. The method is protected and can be made public by the extending classes that allow more than one filename.

Specified by:
addFilename in interface ITrainingSample
Parameters:
pstrFilename - filename to add
Returns:
false if the filename is already there; true otherwise
Since:
0.3.0.6
See Also:
existsFilename(String)

existsFilename

public boolean existsFilename(java.lang.String pstrFilename)
Description copied from interface: ITrainingSample
Checks existence of the file in the training sample. Serves as an indication that we already trained on the given file.

Specified by:
existsFilename in interface ITrainingSample
Parameters:
pstrFilename - filename to check
Returns:
true if the filename is there; false if not

getSubjectID

public final int getSubjectID()
Description copied from interface: ITrainingSample
Retrieves Subject ID of a particular training sample.

Specified by:
getSubjectID in interface ITrainingSample
Returns:
int ID

getDataVector

public final double[] getDataVector()
Description copied from interface: ITrainingSample
Retrieves the data vector.

Specified by:
getDataVector in interface ITrainingSample
Returns:
array of doubles representing the data for this subject

setSubjectID

public void setSubjectID(int piSubjectID)
Description copied from interface: ITrainingSample
Sets new Subject ID.

Specified by:
setSubjectID in interface ITrainingSample
Parameters:
piSubjectID - integer ID

setDataVector

public void setDataVector(double[] padDataVector)
Description copied from interface: ITrainingSample
Sets new mean vector.

Specified by:
setDataVector in interface ITrainingSample
Parameters:
padDataVector - double array representing the mean vector

dumpCSV

public void dumpCSV(java.io.BufferedWriter poBufferedWriter)
             throws StorageException
Writes one training sample to a CSV file.

Parameters:
poBufferedWriter - BufferedWriter
Throws:
StorageException - in case of I/O or otherwise error

restoreCSV

public void restoreCSV(java.io.BufferedReader poBufferedReader)
                throws StorageException
Retrieve one training sample from a CSV file. TODO: FIX, for it's BROKEN.

Parameters:
poBufferedReader - BufferedReader
Throws:
StorageException - in case of I/O or otherwise error

getMeanCount

public int getMeanCount()
Description copied from interface: ITrainingSample
Retrieves current mean count.

Specified by:
getMeanCount in interface ITrainingSample
Returns:
mean count
Since:
0.3.0.6
See Also:
ITrainingSample.getMeanCount()

getMeanVector

public double[] getMeanVector()
Simply retrieves the data vector. Internally calls getDataVector().

Specified by:
getMeanVector in interface ITrainingSample
Returns:
array of doubles representing the mean for that cluster
Since:
0.3.0.6
See Also:
getDataVector()

getMedianVector

public double[] getMedianVector()
Simply retrieves the data vector. Internally calls getDataVector().

Specified by:
getMedianVector in interface ITrainingSample
Returns:
array of doubles representing the mean for that cluster
Since:
0.3.0.6
See Also:
getDataVector()

size

public int size()
Specified by:
size in interface ITrainingSample
Returns:
Since:
0.3.0.6
See Also:
ITrainingSample.size()

clone

public java.lang.Object clone()
Implements Cloneable interface for the TrainingSample object.

Overrides:
clone in class java.lang.Object
Since:
0.3.0.5
See Also:
Object.clone()

toString

public java.lang.String toString()
Provides string representation of the training sample data.

Overrides:
toString in class java.lang.Object
Since:
0.3.0.6
See Also:
Object.toString()

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Returns source code revision information.

Returns:
revision string
Since:
0.3.0.2


SourceForge Logo