Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.distancefunction.adapter
Class SimilarityAdapterAbstract<V extends FeatureVector<V,?>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction<O,D>
              extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction<O,DoubleDistance>
                  extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDoubleDistanceFunction<V>
                      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.adapter.SimilarityAdapterAbstract<V>
Type Parameters:
V - the type of FeatureVector to compute the distances of
All Implemented Interfaces:
DistanceFunction<V,DoubleDistance>, MeasurementFunction<V,DoubleDistance>, Parameterizable
Direct Known Subclasses:
SimilarityAdapterArccos, SimilarityAdapterLinear, SimilarityAdapterLn

public abstract class SimilarityAdapterAbstract<V extends FeatureVector<V,?>>
extends AbstractDoubleDistanceFunction<V>

Adapter from a normalized similarity function to a distance function. Note: The derived distance function will usually not satisfy the triangle equations.

Author:
Erich Schubert

Field Summary
static OptionID SIMILARITY_FUNCTION_ID
          OptionID for SIMILARITY_FUNCTION_PARAM
protected  ClassParameter<NormalizedSimilarityFunction<V,DoubleDistance>> SIMILARITY_FUNCTION_PARAM
          Parameter to specify the similarity function to derive the distance between database objects from.
protected  NormalizedSimilarityFunction<V,DoubleDistance> similarityFunction
          Holds the similarity function.
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
INFINITY_PATTERN
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
SimilarityAdapterAbstract()
          Constructor
 
Method Summary
abstract  DoubleDistance distance(V v1, V v2)
          Distance implementation
 void setDatabase(Database<V> database, boolean verbose, boolean time)
          Set the database that holds the associations for the DatabaseObject for which the measurements should be computed.
 List<String> setParameters(List<String> args)
          Grabs all specified options from the option handler.
 String shortDescription()
          Returns the required input pattern.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDoubleDistanceFunction
infiniteDistance, nullDistance, undefinedDistance, valueOf
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractDistanceFunction
distance, distance, isInfiniteDistance, isNullDistance, isUndefinedDistance
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
getDatabase, matches, requiredInputPattern, setRequiredInputPattern
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.MeasurementFunction
requiredInputPattern
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters
 

Field Detail

SIMILARITY_FUNCTION_ID

public static final OptionID SIMILARITY_FUNCTION_ID
OptionID for SIMILARITY_FUNCTION_PARAM


SIMILARITY_FUNCTION_PARAM

protected final ClassParameter<NormalizedSimilarityFunction<V extends FeatureVector<V,?>,DoubleDistance>> SIMILARITY_FUNCTION_PARAM
Parameter to specify the similarity function to derive the distance between database objects from. Must extend NormalizedSimilarityFunction.

Key: -adapter.similarityfunction

Default value: FractionalSharedNearestNeighborSimilarityFunction


similarityFunction

protected NormalizedSimilarityFunction<V extends FeatureVector<V,?>,DoubleDistance> similarityFunction
Holds the similarity function.

Constructor Detail

SimilarityAdapterAbstract

public SimilarityAdapterAbstract()
Constructor

Method Detail

distance

public abstract DoubleDistance distance(V v1,
                                        V v2)
Distance implementation

Parameters:
v1 - first DatabaseObject
v2 - second DatabaseObject
Returns:
the distance between two given DatabaseObjects according to this distance function

shortDescription

public String shortDescription()
Description copied from class: AbstractMeasurementFunction
Returns the required input pattern.

Specified by:
shortDescription in interface Parameterizable
Overrides:
shortDescription in class AbstractMeasurementFunction<V extends FeatureVector<V,?>,DoubleDistance>
Returns:
Description of the class

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Description copied from class: AbstractParameterizable
Grabs all specified options from the option handler. Any extending class should call this method first and return the returned array without further changes, but after setting further required parameters. An example for overwriting this method taking advantage from the previously (in superclasses) defined options would be:

 {
   List remainingParameters = super.setParameters(args);
   // set parameters for your class
   // for example like this:
   if(isSet(MY_PARAM_VALUE_PARAM))
   {
      myParamValue = getParameterValue(MY_PARAM_VALUE_PARAM);
   }
   .
   .
   .
   return remainingParameters;
   // or in case of attributes requesting parameters themselves
   // return parameterizableAttribbute.setParameters(remainingParameters);
 }
 

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

setDatabase

public void setDatabase(Database<V> database,
                        boolean verbose,
                        boolean time)
Description copied from interface: MeasurementFunction
Set the database that holds the associations for the DatabaseObject for which the measurements should be computed.

Specified by:
setDatabase in interface MeasurementFunction<V extends FeatureVector<V,?>,DoubleDistance>
Overrides:
setDatabase in class AbstractMeasurementFunction<V extends FeatureVector<V,?>,DoubleDistance>
Parameters:
database - Database
verbose - unused
time - unused

Release 0.2 (2009-07-06_1820)