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.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:
Preprocessor<O>, Parameterizable

@Title(value="Shared nearest neighbor Preprocessor")
@Description(value="Computes the k nearest neighbors of objects of a certain database.")
public class SharedNearestNeighborsPreprocessor<O extends DatabaseObject,D extends Distance<D>>
extends AbstractLoggable
implements Preprocessor<O>, Parameterizable

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. This functionality is similar but not identical to MaterializeKNNPreprocessor: While it also computes the k nearest neighbors, it does not keep the actual distances, but organizes the NN set in a TreeSet for fast set operations.

Author:
Arthur Zimek

Field Summary
static OptionID DISTANCE_FUNCTION_ID
          OptionID for DISTANCE_FUNCTION_PARAM
private  ObjectParameter<DistanceFunction<O,D>> 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 function to be used.
static OptionID NUMBER_OF_NEIGHBORS_ID
          OptionID for NUMBER_OF_NEIGHBORS_PARAM
private  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.logging.AbstractLoggable
debug, logger
 
Constructor Summary
SharedNearestNeighborsPreprocessor(Parameterization config)
          Constructor, adhering to Parameterizable
 
Method Summary
 AssociationID<SortedSet<Integer>> getAssociationID()
          Provides the association id used for annotation of the nearest neighbors.
 DistanceFunction<O,D> getDistanceFunction()
          Returns the distance function used by the preprocessor.
 int getNumberOfNeighbors()
          Returns the number of nearest neighbors considered
 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.
 
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
 

Field Detail

NUMBER_OF_NEIGHBORS_ID

public static final OptionID NUMBER_OF_NEIGHBORS_ID
OptionID for NUMBER_OF_NEIGHBORS_PARAM


NUMBER_OF_NEIGHBORS_PARAM

private 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_ID

public static final OptionID DISTANCE_FUNCTION_ID
OptionID for DISTANCE_FUNCTION_PARAM


DISTANCE_FUNCTION_PARAM

private final ObjectParameter<DistanceFunction<O extends DatabaseObject,D extends Distance<D>>> DISTANCE_FUNCTION_PARAM
Parameter to indicate the distance function to be used to ascertain the nearest neighbors.

Default value: EuclideanDistanceFunction

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 function to be used.

Constructor Detail

SharedNearestNeighborsPreprocessor

public SharedNearestNeighborsPreprocessor(Parameterization config)
Constructor, adhering to Parameterizable

Parameters:
config - Parameterization
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

getAssociationID

public AssociationID<SortedSet<Integer>> 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)

getNumberOfNeighbors

public int getNumberOfNeighbors()
Returns the number of nearest neighbors considered

Returns:
number of neighbors considered

getDistanceFunction

public DistanceFunction<O,D> getDistanceFunction()
Returns the distance function used by the preprocessor.

Returns:
distance function used.

Release 0.3 (2010-03-31_1612)