classifiers.usm.distance
Class USMWavDistance

java.lang.Object
  |
  +--coreComponents.DistanceMetric
        |
        +--classifiers.usm.distance.USMDistanceFunction
              |
              +--classifiers.usm.distance.USMWavDistance
All Implemented Interfaces:
OptionHandler, java.io.Serializable

public class USMWavDistance
extends USMDistanceFunction
implements OptionHandler

Class to implement Vitanyi's wonderful Universal Similarity Metric (USM) distance function for wav files! Does exactly what it says on the tin.

Version:
$Version: 1.0$
Author:
David Lindsay (davidl@cs.rhul.ac.uk)
See Also:
Serialized Form

Field Summary
 Instances m_CombinedCompressData
          Combined compressed wav information data set
 java.lang.String m_CombinedCompressFileName
          File name and directory of the combined wav information data set
 Instances m_SingleCompressData
          Single compressed wav information data set
 java.lang.String m_SingleCompressFileName
          File name and directory of the single wav information data set
 
Constructor Summary
USMWavDistance(Instances data)
          Simple constructor, just initialise with the data that is being used to check that it is in the correct format!
 
Method Summary
 USMComplexityCache calculateComplexityAndComplexityStarOf(Instance x, Attribute a)
          Calculates the first K(x) and second order K(x*) complexities of an object x
 double calculateConcatenatedComplexityOf(Instance x, Instance y, USMComplexityCache usmcc)
          Calculates the first K(xy*) complexity of an object x with a compressed object y*
 boolean checkInstance(Instance i)
          Function to check that an individual instance is of the correct format.
 boolean checkInstances(Instances is)
          Function to check that the data instances are in the correct format.
 java.lang.String[] getOptions()
          Gets the current settings of the USM Wav Distance metric
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] args)
          Test class for the object!
 void reset(Instances data)
          Can we put constructor stuff in here?
 double returnTheSizeOfCompressedConcatWav(java.lang.String wavFileName1, java.lang.String wavFileName2)
          Returns the compressed concatenated wav file size in bytes
 double returnTheSizeOfCompressedWav(java.lang.String wavFileName)
          Returns the compressed wav file size in bytes
 void setCombinedCompressedData(java.lang.String combinedString)
          Set the combined compressed wav file data
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSingleCompressedData(java.lang.String singleString)
          Set the single compressed wav file data
 void updateRanges(Instance inst1)
          Update the ranges of the distance metric with a new training instance.
 
Methods inherited from class classifiers.usm.distance.USMDistanceFunction
calculateUSM, definePrefix, distance, findAttributesWithPrefix, findInstanceInCache, returnInstanceCache, toString, updateInstanceCache
 
Methods inherited from class coreComponents.DistanceMetric
forName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_SingleCompressFileName

public java.lang.String m_SingleCompressFileName
File name and directory of the single wav information data set


m_SingleCompressData

public Instances m_SingleCompressData
Single compressed wav information data set


m_CombinedCompressFileName

public java.lang.String m_CombinedCompressFileName
File name and directory of the combined wav information data set


m_CombinedCompressData

public Instances m_CombinedCompressData
Combined compressed wav information data set

Constructor Detail

USMWavDistance

public USMWavDistance(Instances data)
Simple constructor, just initialise with the data that is being used to check that it is in the correct format!

Parameters:
data - the Instance format to be initialised
Method Detail

reset

public void reset(Instances data)
Can we put constructor stuff in here?

Specified by:
reset in class DistanceMetric

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface OptionHandler
Returns:
an enumeration of all the available options.

getOptions

public java.lang.String[] getOptions()
Gets the current settings of the USM Wav Distance metric

Specified by:
getOptions in interface OptionHandler
Returns:
an array of strings suitable for passing to setOptions()

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

-e single compressed file name

This makes the user specify the single file name.
-f combined compressed file name

This makes the user specify the combined file name

Specified by:
setOptions in interface OptionHandler
Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

checkInstances

public boolean checkInstances(Instances is)
Function to check that the data instances are in the correct format.

Specified by:
checkInstances in class USMDistanceFunction
Parameters:
is - the instances to be checked
Returns:
true if the Instances are in the correct format for this distance function, else false

setSingleCompressedData

public void setSingleCompressedData(java.lang.String singleString)
Set the single compressed wav file data


setCombinedCompressedData

public void setCombinedCompressedData(java.lang.String combinedString)
Set the combined compressed wav file data


checkInstance

public boolean checkInstance(Instance i)
Function to check that an individual instance is of the correct format. This may be a little inefficient with lots of distance calculations.

Specified by:
checkInstance in class USMDistanceFunction
Parameters:
i - the instance to be checked
Returns:
true if the instance has the same fromat as initially set, else false

returnTheSizeOfCompressedWav

public double returnTheSizeOfCompressedWav(java.lang.String wavFileName)
Returns the compressed wav file size in bytes


returnTheSizeOfCompressedConcatWav

public double returnTheSizeOfCompressedConcatWav(java.lang.String wavFileName1,
                                                 java.lang.String wavFileName2)
Returns the compressed concatenated wav file size in bytes


calculateComplexityAndComplexityStarOf

public USMComplexityCache calculateComplexityAndComplexityStarOf(Instance x,
                                                                 Attribute a)
Calculates the first K(x) and second order K(x*) complexities of an object x

Specified by:
calculateComplexityAndComplexityStarOf in class USMDistanceFunction
Parameters:
x - the instance to calculate the complexities for
Returns:
the complexitys in a paired array [ K(x) , K(x*) ]

calculateConcatenatedComplexityOf

public double calculateConcatenatedComplexityOf(Instance x,
                                                Instance y,
                                                USMComplexityCache usmcc)
Calculates the first K(xy*) complexity of an object x with a compressed object y*

Specified by:
calculateConcatenatedComplexityOf in class USMDistanceFunction
Parameters:
x - the instance to use
y - the instance to use the compression of
Returns:
the complexitys of the concatenated string xy (not with a comma!)

updateRanges

public void updateRanges(Instance inst1)
Update the ranges of the distance metric with a new training instance.

Specified by:
updateRanges in class DistanceMetric
Parameters:
inst1 - the instance to update with
Returns:
nothing

main

public static void main(java.lang.String[] args)
Test class for the object!



Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London