marf.Classification
Class Classification

java.lang.Object
  extended by marf.Storage.StorageManager
      extended by marf.Classification.Classification
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, IClassification, IStorageManager
Direct Known Subclasses:
CosineSimilarityMeasure, Distance, NeuralNetwork, RandomClassification, Stochastic

public abstract class Classification
extends StorageManager
implements IClassification

Abstract Classification Module. A generic implementation of the IClassification interface. The derivatives must inherit from this class, and if they cannot, they should implement IClassification themselves.

$Id: Classification.java,v 1.50 2008/02/19 03:20:30 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.50 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  double[] adFeatureVector
          Local reference to the array of features, either obtained from the feature extraction module or passed directly to train() or classify.
protected  IFeatureExtraction oFeatureExtraction
          Reference to the enclosed FeatureExtraction object.
protected  ResultSet oResultSet
          Classification result set.
protected  TrainingSet oTrainingSet
          TrainingSet Container.
 
Fields inherited from class marf.Storage.StorageManager
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Classification.IClassification
MARF_INTERFACE_CODE_REVISION
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS
 
Constructor Summary
protected Classification(IFeatureExtraction poFeatureExtraction)
          Generic Classification Constructor.
 
Method Summary
 boolean classify()
          Generic classification routine that assumes a presence of a valid non-null feature extraction module for pipeline operation.
 java.lang.Object clone()
          Implements Cloneable interface for the Classification object.
 void dump()
          Generic implementation of dump() to dump the TrainingSet.
 IFeatureExtraction getFeatureExtraction()
          Retrieves the features source.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 ResultSet getResultSet()
          Retrieves the enclosed result set.
protected  java.lang.String getTrainingSetFilename()
          Constructs a global cluster file name for the TrainingSet.
static TrainingSet loadTrainingSet(int piDumpMode, java.lang.String pstrFilename)
          Allows loading of the training sets for debugging and browsing purposes by external classes.
 void restore()
          Generic implementation of restore() for TrainingSet.
 void setFeatureExtraction(IFeatureExtraction poFeatureExtraction)
          Allows setting the features source.
 boolean train()
          Generic training routine for building/updating mean vectors in the training set.
 boolean train(double[] padFeatureVector)
          Generic training routine for building/updating mean vectors in the training set.
 
Methods inherited from class marf.Storage.StorageManager
backSynchronizeObject, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, enableDumpOnNotFound, equals, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, getObjectToSerialize, hashCode, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface marf.Classification.IClassification
classify, getResult
 

Field Detail

oFeatureExtraction

protected IFeatureExtraction oFeatureExtraction
Reference to the enclosed FeatureExtraction object.


oTrainingSet

protected TrainingSet oTrainingSet
TrainingSet Container.


adFeatureVector

protected double[] adFeatureVector
Local reference to the array of features, either obtained from the feature extraction module or passed directly to train() or classify. Used in prevention of NullPointerException, bug #1539695.

Since:
0.3.0.6
See Also:
train(double[]), IClassification.classify(double[])

oResultSet

protected ResultSet oResultSet
Classification result set. May contain one or more results (in case of similarity).

Since:
0.3.0.2
Constructor Detail

Classification

protected Classification(IFeatureExtraction poFeatureExtraction)
Generic Classification Constructor.

Parameters:
poFeatureExtraction - FeatureExtraction module reference
Method Detail

train

public boolean train()
              throws ClassificationException
Generic training routine for building/updating mean vectors in the training set. Assumes presence of a non-null feature extraction module for pipelining. Can be overridden, and if the overriding classifier is using TrainingSet, it should call super.train();

Specified by:
train in interface IClassification
Returns:
true if training was successful (i.e. mean vector was updated); false otherwise
Throws:
ClassificationException - if there was a problem while training
See Also:
TrainingSet

train

public boolean train(double[] padFeatureVector)
              throws ClassificationException
Generic training routine for building/updating mean vectors in the training set. Can be overridden, and if the overriding classifier is using TrainingSet, it should call super.train();

Specified by:
train in interface IClassification
Parameters:
padFeatureVector - feature vector to train on
Returns:
true if training was successful (i.e. mean vector was updated); false otherwise
Throws:
ClassificationException - if there was a problem while training
Since:
0.3.0.6
See Also:
TrainingSet

classify

public boolean classify()
                 throws ClassificationException
Generic classification routine that assumes a presence of a valid non-null feature extraction module for pipeline operation.

Specified by:
classify in interface IClassification
Returns:
true if classification was successful; false otherwise
Throws:
ClassificationException - if there was an error while classifying
Since:
0.3.0.6
See Also:
IClassification.classify()

dump

public void dump()
          throws StorageException
Generic implementation of dump() to dump the TrainingSet.

Specified by:
dump in interface IStorageManager
Overrides:
dump in class StorageManager
Throws:
StorageException - if there's a problem saving training set to disk
Since:
0.2.0
See Also:
IStorageManager.DUMP_GZIP_BINARY, IStorageManager.DUMP_BINARY, StorageManager.dumpGzipBinary(), StorageManager.dumpCSV(), StorageManager.dumpBinary(), StorageManager.dumpXML(), StorageManager.dumpHTML(), StorageManager.dumpSQL(), StorageManager.backSynchronizeObject(), StorageManager.iCurrentDumpMode

restore

public void restore()
             throws StorageException
Generic implementation of restore() for TrainingSet.

Specified by:
restore in interface IStorageManager
Overrides:
restore in class StorageManager
Throws:
StorageException - if there is a problem loading the training set from disk
Since:
0.2.0
See Also:
IStorageManager.DUMP_GZIP_BINARY, IStorageManager.DUMP_BINARY, StorageManager.dumpGzipBinary(), StorageManager.dumpCSV(), StorageManager.dumpBinary(), StorageManager.dumpXML(), StorageManager.dumpHTML(), StorageManager.dumpSQL(), StorageManager.backSynchronizeObject(), StorageManager.iCurrentDumpMode

loadTrainingSet

public static TrainingSet loadTrainingSet(int piDumpMode,
                                          java.lang.String pstrFilename)
                                   throws StorageException
Allows loading of the training sets for debugging and browsing purposes by external classes.

Parameters:
piDumpMode -
pstrFilename -
Returns:
loaded training set bean if I/O was successful
Throws:
StorageException
Since:
0.3.0.6

getResultSet

public ResultSet getResultSet()
Retrieves the enclosed result set.

Specified by:
getResultSet in interface IClassification
Returns:
the enclosed ResultSet object
Since:
0.3.0.2

getTrainingSetFilename

protected java.lang.String getTrainingSetFilename()
Constructs a global cluster file name for the TrainingSet.

Filename is constructed using fully-qualified class of either TrainingSet or a classifier name with global clustering info such as preprocessing and feature extraction methods, so that only that cluster can be reloaded after.

May be overridden by the derivatives when necessary.

Returns:
String, filename
Since:
0.2.0

getFeatureExtraction

public IFeatureExtraction getFeatureExtraction()
Retrieves the features source.

Specified by:
getFeatureExtraction in interface IClassification
Returns:
returns the FeatureExtraction reference
Since:
0.3.0.4

setFeatureExtraction

public void setFeatureExtraction(IFeatureExtraction poFeatureExtraction)
Allows setting the features source.

Specified by:
setFeatureExtraction in interface IClassification
Parameters:
poFeatureExtraction - the FeatureExtraction object to set
Since:
0.3.0.4

clone

public java.lang.Object clone()
Implements Cloneable interface for the Classification object. The contained FeatureExtraction isn't cloned at this point, and is just assigned to the clone.

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

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Returns:
revision string
Since:
0.3.0.2


SourceForge Logo