at.tuwien.ifs.somtoolbox.data
Class DataBaseSOMLibSparseInputData

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.data.AbstractSOMLibSparseInputData
      extended by at.tuwien.ifs.somtoolbox.data.DataBaseSOMLibSparseInputData
All Implemented Interfaces:
InputData

public class DataBaseSOMLibSparseInputData
extends AbstractSOMLibSparseInputData

Implements InputData by reading the vector information from a database.

Version:
$Id: DataBaseSOMLibSparseInputData.java 3883 2010-11-02 17:13:23Z frank $
Author:
liegl, Rudolf Mayer

Field Summary
private  MySQLConnector dbConnector
           
 
Fields inherited from class at.tuwien.ifs.somtoolbox.data.AbstractSOMLibSparseInputData
classInfo, contentType, dataNames, dim, ERROR_MESSAGE_FILE_FORMAT_CORRUPT, featureMatrixCols, featureMatrixRows, isNormalized, meanVector, mqe0, nameCache, numVectors, rand, source, templateVector
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.data.InputData
inputFileNameSuffix, MISSING_VALUE
 
Constructor Summary
DataBaseSOMLibSparseInputData(MySQLConnector dbConnector, boolean sparse, boolean norm, int numCacheBlocks, long seed)
           
DataBaseSOMLibSparseInputData(MySQLConnector dbConnector, boolean sparse, String classInfoFileName, boolean norm, int numCacheBlocks, long seed)
           
 
Method Summary
protected  void calculateMeanVector()
          Initialise the mean-vector.
private  String getErrorMessage(Exception e)
           
 InputDatum getInputDatum(int index)
          Get an input datum with a specified index.
 double[] getInputVector(int d)
          Get the vector for the input datum of the specified index
 double getValue(int x, int y)
          Returns the value of the y-th feature of input vector x.
 double mqe0(DistanceMetric metric)
          Calculates the mean quantisation error of the top-level unit.
private  cern.colt.matrix.DoubleMatrix1D readVectorFromDataBase(int rowindex)
          Read a vector from the database, identified by the given index.
private  void readVectorMetaDataFromDataBase()
          Read input meta data from the database.
 InputData subset(String[] names)
          TODO: this reads the whole subset into the memory.
 
Methods inherited from class at.tuwien.ifs.somtoolbox.data.AbstractSOMLibSparseInputData
classInformation, create, dim, equals, getByNameDistanceSorted, getContentType, getData, getData, getDataIntervals, getDataSource, getDistanceMatrix, getDistances, getFeatureDensities, getFeatureMatrixColumns, getFeatureMatrixRows, getFileNameSuffix, getFormatName, getInputDatum, getInputDatum, getInputDatumIndex, getLabel, getLabels, getMaxValue, getMeanVector, getMeanVector, getMinValue, getNearestDistances, getNearestN, getNearestN, getNearestNUnsorted, getRandomInputDatum, initDistanceMatrix, isNormalizedToUnitLength, numVectors, setClassInfo, setTemplateVector, templateVector, transformValues
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbConnector

private MySQLConnector dbConnector
Constructor Detail

DataBaseSOMLibSparseInputData

public DataBaseSOMLibSparseInputData(MySQLConnector dbConnector,
                                     boolean sparse,
                                     boolean norm,
                                     int numCacheBlocks,
                                     long seed)

DataBaseSOMLibSparseInputData

public DataBaseSOMLibSparseInputData(MySQLConnector dbConnector,
                                     boolean sparse,
                                     String classInfoFileName,
                                     boolean norm,
                                     int numCacheBlocks,
                                     long seed)
                              throws SOMToolboxException
Throws:
SOMToolboxException
Method Detail

readVectorMetaDataFromDataBase

private void readVectorMetaDataFromDataBase()
Read input meta data from the database. This includes:


getInputDatum

public InputDatum getInputDatum(int index)
Description copied from interface: InputData
Get an input datum with a specified index.

Parameters:
index - the index of the input datum.
Returns:
the input datum.

getInputVector

public double[] getInputVector(int d)
Description copied from interface: InputData
Get the vector for the input datum of the specified index


readVectorFromDataBase

private cern.colt.matrix.DoubleMatrix1D readVectorFromDataBase(int rowindex)
Read a vector from the database, identified by the given index.

Parameters:
rowindex - the index of the vector.
Returns:
the input vector.

mqe0

public double mqe0(DistanceMetric metric)
Description copied from interface: InputData
Calculates the mean quantisation error of the top-level unit.

Parameters:
metric - the metric to use for distance calculation.
Returns:
the mqe0.

subset

public InputData subset(String[] names)
TODO: this reads the whole subset into the memory.

Parameters:
names - the label names of the desired subset data.
Returns:
a subset of the data.
See Also:
InputData.subset(java.lang.String[])

calculateMeanVector

protected void calculateMeanVector()
                            throws SQLException
Initialise the mean-vector.

Throws:
SQLException

getErrorMessage

private String getErrorMessage(Exception e)

getValue

public double getValue(int x,
                       int y)
Description copied from interface: InputData
Returns the value of the y-th feature of input vector x.