Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.distancefunction
Class KernelBasedLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>

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<O>
                      extended by de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractLocallyWeightedDistanceFunction<O,P>
                          extended by de.lmu.ifi.dbs.elki.distance.distancefunction.KernelBasedLocallyWeightedDistanceFunction<O,P>
All Implemented Interfaces:
DistanceFunction<O,DoubleDistance>, MeasurementFunction<O,DoubleDistance>, Loggable, Parameterizable

public class KernelBasedLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>
extends AbstractLocallyWeightedDistanceFunction<O,P>

Provides a kernel based locally weighted distance function. It is defined as follows: result = max{distP(P,Q), distQ(Q,P)}, where distP(P,Q) computes the quadratic form distance on the weak eigenvectors of the kernel matrix of P between two vectors P and Q in feature space. Computation of the distance component of the weak eigenvectors is done indirectly by computing the difference between the complete kernel distance and the distance component of the strong eigenvectors: distP(P,Q) = distP_weak(P,Q) = sqrt(distP_complete(P,Q)^2 - distP_strong(P,Q)^2) KP_complete(P,Q) is the kernel derived distance between P and Q. The distance component of the strong eigenvectors KP_strong(P,Q) is computed as follows: First, the vectors P and Q are projected onto the strong eigenvectors of the kernel matrix of P, which results in the two vectors Pp and Qp. Then, the euklidean distance is used to compute the distance between Pp and Qp. In case of the linear kernel function, this distance is identical to those computed by the LocallyWeightedDistanceFunction with parameters big = 1.0 and small = 0.0

Author:
Simon Paradies

Field Summary
static String DEFAULT_KERNEL_FUNCTION_CLASS
          The default kernel function.
static String KERNEL_FUNCTION_CLASS_D
          Description for parameter kernel.
static String KERNEL_FUNCTION_CLASS_P
          Parameter for kernel.
private  KernelFunction<O,DoubleDistance> kernelFunction
          The kernel function that is used.
private  KernelMatrix<O> kernelMatrix
          The global precomputed kernel matrix
 
Fields inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractLocallyWeightedDistanceFunction
DEFAULT_PREPROCESSOR_CLASS, PREPROCESSOR_CLASS_D
 
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
 
Constructor Summary
KernelBasedLocallyWeightedDistanceFunction()
          Provides a kernel based locally weighted distance function.
 
Method Summary
private  double computeDistance(O o1, O o2)
          Computes the distance between two given real vectors according to this distance function.
 DoubleDistance distance(O o1, O o2)
          Computes the distance between two given DatabaseObjects according to this distance function.
(package private)  AssociationID getAssociationID()
          Returns the assocoiation ID for the association to be set by the preprocessor.
 List<AttributeSettings> getAttributeSettings()
          Returns the settings of all options assigned to the option handler.
 void setDatabase(Database<O> database, boolean verbose, boolean time)
          Set the database that holds the associations for the DatabaseObject for which the measurements should be computed.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractLocallyWeightedDistanceFunction
description
 
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, checkGlobalParameterConstraints, deleteOption, description, description, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, 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, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

DEFAULT_KERNEL_FUNCTION_CLASS

public static final String DEFAULT_KERNEL_FUNCTION_CLASS
The default kernel function.


KERNEL_FUNCTION_CLASS_D

public static final String KERNEL_FUNCTION_CLASS_D
Description for parameter kernel.


KERNEL_FUNCTION_CLASS_P

public static final String KERNEL_FUNCTION_CLASS_P
Parameter for kernel.

See Also:
Constant Field Values

kernelFunction

private KernelFunction<O extends RealVector<O,?>,DoubleDistance> kernelFunction
The kernel function that is used.


kernelMatrix

private KernelMatrix<O extends RealVector<O,?>> kernelMatrix
The global precomputed kernel matrix

Constructor Detail

KernelBasedLocallyWeightedDistanceFunction

public KernelBasedLocallyWeightedDistanceFunction()
Provides a kernel based locally weighted distance function.

Method Detail

distance

public DoubleDistance distance(O o1,
                               O o2)
Computes the distance between two given DatabaseObjects according to this distance function.

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

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(String[])

getAttributeSettings

public List<AttributeSettings> getAttributeSettings()
Description copied from class: AbstractParameterizable
Returns the settings of all options assigned to the option handler.

Specified by:
getAttributeSettings in interface Parameterizable
Overrides:
getAttributeSettings in class AbstractLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>
Returns:
the setting of the attributes of the parameterizable
See Also:
Parameterizable.getAttributeSettings()

computeDistance

private double computeDistance(O o1,
                               O o2)
Computes the distance between two given real vectors according to this distance function.

Parameters:
o1 - first FeatureVector
o2 - second FeatureVector
Returns:
the distance between two given real vectors according to this distance function

setDatabase

public void setDatabase(Database<O> 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<O extends RealVector<O,?>,DoubleDistance>
Overrides:
setDatabase in class AbstractLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>
Parameters:
database - the database to be set
verbose - flag to allow verbose messages while performing the method
time - flag to request output of performance time
See Also:
MeasurementFunction.setDatabase(de.lmu.ifi.dbs.elki.database.Database, boolean, boolean)

getAssociationID

AssociationID getAssociationID()
Returns the assocoiation ID for the association to be set by the preprocessor.

Specified by:
getAssociationID in class AbstractLocallyWeightedDistanceFunction<O extends RealVector<O,?>,P extends Preprocessor<O>>

Release 0.1 (2008-07-10_1838)