Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.preprocessing
Class SharedNearestNeighborsPreprocessor<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.preprocessing.SharedNearestNeighborsPreprocessor<O,D>
Type Parameters:
O - the type of database objects the preprocessor can be applied to
D - the type of distance the used distance function will return
All Implemented Interfaces:
Loggable, Preprocessor<O>, Parameterizable

public class SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>
extends AbstractParameterizable
implements Preprocessor<O>

A preprocessor for annotation of the ids of nearest neighbors to each database object.

The k nearest neighbors are assigned based on an arbitrary distance function.

The association is annotated using the association id AssociationID.SHARED_NEAREST_NEIGHBORS_SET.

Author:
Arthur Zimek

Field Summary
static ClassParameter<DistanceFunction> DISTANCE_FUNCTION_PARAM
          Parameter to indicate the distance function to be used to ascertain the nearest neighbors.
private  DistanceFunction<O,D> distanceFunction
          Hold the distance funciton to be used.
static IntParameter NUMBER_OF_NEIGHBORS_PARAM
          Parameter to indicate the number of neighbors to be taken into account for the shared-nearest-neighbor similarity.
private  int numberOfNeighbors
          Holds the number of nearest neighbors to be used.
 
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
SharedNearestNeighborsPreprocessor()
          Provides a SharedNearestNeighborPreprocessor.
 
Method Summary
 String description()
          Provides a short description of the purpose of this class.
 AssociationID<SortedSet> getAssociationID()
          Provides the association id used for annotation of the nearest neighbors.
 void run(Database<O> database, boolean verbose, boolean time)
          Annotates the nearest neighbors based on the values of numberOfNeighbors and distanceFunction to each database object.
 String[] setParameters(String[] args)
          Sets the parameter values of NUMBER_OF_NEIGHBORS_PARAM and DISTANCE_FUNCTION_PARAM to numberOfNeighbors and distanceFunction, respectively.
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, checkGlobalParameterConstraints, deleteOption, description, description, getAttributeSettings, 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.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, getAttributeSettings, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

NUMBER_OF_NEIGHBORS_PARAM

public static final IntParameter NUMBER_OF_NEIGHBORS_PARAM
Parameter to indicate the number of neighbors to be taken into account for the shared-nearest-neighbor similarity.

Default value: 1

Key: sharedNearestNeighbors


DISTANCE_FUNCTION_PARAM

public static final ClassParameter<DistanceFunction> DISTANCE_FUNCTION_PARAM
Parameter to indicate the distance function to be used to ascertain the nearest neighbors.

Default value: EuklideanDistanceFunction

Key: SNNDistanceFunction


numberOfNeighbors

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


distanceFunction

private DistanceFunction<O extends DatabaseObject,D extends Distance<D>> distanceFunction
Hold the distance funciton to be used.

Constructor Detail

SharedNearestNeighborsPreprocessor

public SharedNearestNeighborsPreprocessor()
Provides a SharedNearestNeighborPreprocessor.

Method Detail

run

public void run(Database<O> database,
                boolean verbose,
                boolean time)
Annotates the nearest neighbors based on the values of numberOfNeighbors and distanceFunction to each database object.

Specified by:
run in interface Preprocessor<O extends DatabaseObject>
Parameters:
database - the database for which the preprocessing is performed
verbose - flag to allow verbose messages while performing the algorithm
time - flag to request output of performance time
See Also:
Preprocessor.run(de.lmu.ifi.dbs.elki.database.Database,boolean,boolean)

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Sets the parameter values of NUMBER_OF_NEIGHBORS_PARAM and DISTANCE_FUNCTION_PARAM to numberOfNeighbors and distanceFunction, respectively.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
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:
AbstractParameterizable.setParameters(java.lang.String[])

getAssociationID

public AssociationID<SortedSet> getAssociationID()
Provides the association id used for annotation of the nearest neighbors.

Returns:
the association id used for annotation of the nearest neighbors (AssociationID.SHARED_NEAREST_NEIGHBORS_SET)

description

public String description()
Provides a short description of the purpose of this class.

Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
String a description of the class and the required parameters
See Also:
AbstractParameterizable.description()

Release 0.1 (2008-07-10_1838)