Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.distance.similarityfunction
Class FractionalSharedNearestNeighborSimilarityFunction<O extends DatabaseObject,D extends Distance<D>>

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.similarityfunction.AbstractSimilarityFunction<O,D>
                  extended by de.lmu.ifi.dbs.elki.distance.similarityfunction.AbstractPreprocessorBasedSimilarityFunction<O,SharedNearestNeighborsPreprocessor<O,D>,DoubleDistance>
                      extended by de.lmu.ifi.dbs.elki.distance.similarityfunction.FractionalSharedNearestNeighborSimilarityFunction<O,D>
Type Parameters:
O - object type
D - distance type
All Implemented Interfaces:
MeasurementFunction<O,DoubleDistance>, PreprocessorBasedMeasurementFunction<O,SharedNearestNeighborsPreprocessor<O,D>,DoubleDistance>, NormalizedSimilarityFunction<O,DoubleDistance>, SimilarityFunction<O,DoubleDistance>, PreprocessorClient<SharedNearestNeighborsPreprocessor<O,D>,O>, Parameterizable

public class FractionalSharedNearestNeighborSimilarityFunction<O extends DatabaseObject,D extends Distance<D>>
extends AbstractPreprocessorBasedSimilarityFunction<O,SharedNearestNeighborsPreprocessor<O,D>,DoubleDistance>
implements NormalizedSimilarityFunction<O,DoubleDistance>

Author:
Arthur Zimek

Field Summary
private  ArrayList<Pair<O,SortedSet<Integer>>> cache
          Cache for objects not handled by the preprocessor
private  int cachesize
           
private  int numberOfNeighbors
          Holds the number of nearest neighbors to be used.
 
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
FractionalSharedNearestNeighborSimilarityFunction()
          Provides a SharedNearestNeighborSimilarityFunction with a pattern defined to accept Strings that define a non-negative Integer.
 
Method Summary
 AssociationID<SortedSet<Integer>> getAssociationID()
          Returns the association ID for the association to be set by the preprocessor.
 String getDefaultPreprocessorClassName()
          Returns the name of the default preprocessor.
private  SortedSet<Integer> getNeighbors(O obj)
          Wrapper to handle objects not preprocessed with a cache for performance.
 String getPreprocessorDescription()
          Returns the description for the preprocessor parameter.
 Class<SharedNearestNeighborsPreprocessor<O,D>> getPreprocessorSuperClass()
          Returns the super class for the preprocessor parameter.
 DoubleDistance infiniteDistance()
          Provides an infinite distance.
 boolean isInfiniteDistance(DoubleDistance distance)
          Returns true, if the given distance is an infinite distance, false otherwise.
 boolean isNullDistance(DoubleDistance distance)
          Returns true, if the given distance is a null distance, false otherwise.
 boolean isUndefinedDistance(DoubleDistance distance)
          Returns true, if the given distance is an undefined distance, false otherwise.
 DoubleDistance nullDistance()
          Provides a null distance.
 List<String> setParameters(List<String> args)
          Calls the super method and passes the remaining parameters to the AbstractPreprocessorBasedSimilarityFunction.preprocessorHandler.
 DoubleDistance similarity(Integer id1, Integer id2)
          Returns the similarity between the two objects specified by their object ids.
 DoubleDistance similarity(O o1, O o2)
          Computes the similarity between two given DatabaseObjects according to this similarity function.
 DoubleDistance undefinedDistance()
          Provides an undefined distance.
 DoubleDistance valueOf(String pattern)
          Provides a measurement suitable to this measurement function based on the given pattern.
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.similarityfunction.AbstractPreprocessorBasedSimilarityFunction
getPreprocessor, setDatabase
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.similarityfunction.AbstractSimilarityFunction
similarity
 
Methods inherited from class de.lmu.ifi.dbs.elki.distance.AbstractMeasurementFunction
getDatabase, matches, requiredInputPattern, setRequiredInputPattern, shortDescription
 
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.similarityfunction.SimilarityFunction
similarity
 
Methods inherited from interface de.lmu.ifi.dbs.elki.distance.MeasurementFunction
requiredInputPattern, setDatabase
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters, shortDescription
 

Field Detail

cachesize

private int cachesize

cache

private ArrayList<Pair<O extends DatabaseObject,SortedSet<Integer>>> cache
Cache for objects not handled by the preprocessor


numberOfNeighbors

private int numberOfNeighbors
Holds the number of nearest neighbors to be used.

Constructor Detail

FractionalSharedNearestNeighborSimilarityFunction

public FractionalSharedNearestNeighborSimilarityFunction()
Provides a SharedNearestNeighborSimilarityFunction with a pattern defined to accept Strings that define a non-negative Integer.

Method Detail

similarity

public DoubleDistance similarity(Integer id1,
                                 Integer id2)
Description copied from interface: SimilarityFunction
Returns the similarity between the two objects specified by their object ids.

Specified by:
similarity in interface SimilarityFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
id1 - first object id
id2 - second object id
Returns:
the similarity between the two objects specified by their object ids

getNeighbors

private SortedSet<Integer> getNeighbors(O obj)
Wrapper to handle objects not preprocessed with a cache for performance.

Parameters:
obj - query object
Returns:
neighbors

similarity

public DoubleDistance similarity(O o1,
                                 O o2)
Description copied from interface: SimilarityFunction
Computes the similarity between two given DatabaseObjects according to this similarity function.

Specified by:
similarity in interface SimilarityFunction<O extends DatabaseObject,DoubleDistance>
Overrides:
similarity in class AbstractSimilarityFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
o1 - first DatabaseObject
o2 - second DatabaseObject
Returns:
the similarity between two given DatabaseObjects according to this similarity function

infiniteDistance

public DoubleDistance infiniteDistance()
Description copied from interface: MeasurementFunction
Provides an infinite distance.

Specified by:
infiniteDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Returns:
an infinite distance

isInfiniteDistance

public boolean isInfiniteDistance(DoubleDistance distance)
Description copied from interface: MeasurementFunction
Returns true, if the given distance is an infinite distance, false otherwise.

Specified by:
isInfiniteDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
distance - the distance to be tested on infinity
Returns:
true, if the given distance is an infinite distance, false otherwise

isNullDistance

public boolean isNullDistance(DoubleDistance distance)
Description copied from interface: MeasurementFunction
Returns true, if the given distance is a null distance, false otherwise.

Specified by:
isNullDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
distance - the distance to be tested whether it is a null distance
Returns:
true, if the given distance is a null distance, false otherwise

isUndefinedDistance

public boolean isUndefinedDistance(DoubleDistance distance)
Description copied from interface: MeasurementFunction
Returns true, if the given distance is an undefined distance, false otherwise.

Specified by:
isUndefinedDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
distance - the distance to be tested whether it is undefined
Returns:
true, if the given distance is an undefined distance, false otherwise

nullDistance

public DoubleDistance nullDistance()
Description copied from interface: MeasurementFunction
Provides a null distance.

Specified by:
nullDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Returns:
a null distance

undefinedDistance

public DoubleDistance undefinedDistance()
Description copied from interface: MeasurementFunction
Provides an undefined distance.

Specified by:
undefinedDistance in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Returns:
an undefined distance

valueOf

public DoubleDistance valueOf(String pattern)
                       throws IllegalArgumentException
Description copied from interface: MeasurementFunction
Provides a measurement suitable to this measurement function based on the given pattern.

Specified by:
valueOf in interface MeasurementFunction<O extends DatabaseObject,DoubleDistance>
Parameters:
pattern - a pattern defining a similarity suitable to this measurement function
Returns:
a measurement suitable to this measurement function based on the given pattern
Throws:
IllegalArgumentException - if the given pattern is not compatible with the requirements of this measurement function

getAssociationID

public AssociationID<SortedSet<Integer>> getAssociationID()
Description copied from interface: PreprocessorClient
Returns the association ID for the association to be set by the preprocessor.

Specified by:
getAssociationID in interface PreprocessorClient<SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>,O extends DatabaseObject>
Returns:
the association ID for the association to be set by the preprocessor, which is AssociationID.SHARED_NEAREST_NEIGHBORS_SET

getDefaultPreprocessorClassName

public String getDefaultPreprocessorClassName()
Description copied from interface: PreprocessorClient
Returns the name of the default preprocessor.

Specified by:
getDefaultPreprocessorClassName in interface PreprocessorClient<SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>,O extends DatabaseObject>
Returns:
the name of the default preprocessor, which is SharedNearestNeighborsPreprocessor

getPreprocessorDescription

public String getPreprocessorDescription()
Description copied from interface: PreprocessorClient
Returns the description for the preprocessor parameter.

Specified by:
getPreprocessorDescription in interface PreprocessorClient<SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>,O extends DatabaseObject>
Returns:
the description for the preprocessor parameter

getPreprocessorSuperClass

public Class<SharedNearestNeighborsPreprocessor<O,D>> getPreprocessorSuperClass()
Description copied from interface: PreprocessorClient
Returns the super class for the preprocessor parameter.

Specified by:
getPreprocessorSuperClass in interface PreprocessorClient<SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>,O extends DatabaseObject>
Returns:
the super class for the preprocessor, which is SharedNearestNeighborsPreprocessor

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Description copied from class: AbstractPreprocessorBasedSimilarityFunction
Calls the super method and passes the remaining parameters to the AbstractPreprocessorBasedSimilarityFunction.preprocessorHandler.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractPreprocessorBasedSimilarityFunction<O extends DatabaseObject,SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>,DoubleDistance>
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

Release 0.2 (2009-07-06_1820)