Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.preprocessing
Class MaterializeKNNPreprocessor<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.MaterializeKNNPreprocessor<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
Direct Known Subclasses:
SpatialApproximationMaterializeKNNPreprocessor

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

A preprocessor for annotation of the k nearest neighbors (and their distances) to each database object. Used for example by LOF.

Author:
Erich Schubert

Field Summary
static OptionID DISTANCE_FUNCTION_ID
          OptionID for DISTANCE_FUNCTION_PARAM
 ClassParameter<DistanceFunction<O,D>> DISTANCE_FUNCTION_PARAM
          Parameter to indicate the distance function to be used to ascertain the nearest neighbors.
protected  DistanceFunction<O,D> distanceFunction
          Hold the distance function to be used.
protected  int k
          Holds the value of K_PARAM.
static OptionID K_ID
          OptionID for K_PARAM
private  IntParameter K_PARAM
          Parameter to specify the number of nearest neighbors of an object to be materialized. must be an integer greater than 1.
protected  HashMap<Integer,List<DistanceResultPair<D>>> materialized
          Materialized neighborhood
 
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
MaterializeKNNPreprocessor()
          Provides a k nearest neighbors Preprocessor.
 
Method Summary
 HashMap<Integer,List<DistanceResultPair<D>>> getMaterialized()
          Materialize a neighborhood.
 void run(Database<O> database, boolean verbose, boolean time)
          Annotates the nearest neighbors based on the values of k and distanceFunction to each database object.
 List<String> setParameters(List<String> args)
          Sets the parameter values of K_PARAM and DISTANCE_FUNCTION_PARAM to k and distanceFunction, respectively.
 String shortDescription()
          Provides a short description of the purpose of this class.
 
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.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, collectOptions, getParameters
 

Field Detail

K_ID

public static final OptionID K_ID
OptionID for K_PARAM


K_PARAM

private final IntParameter K_PARAM
Parameter to specify the number of nearest neighbors of an object to be materialized. must be an integer greater than 1.

Key: -materialize.k


k

protected int k
Holds the value of K_PARAM.


DISTANCE_FUNCTION_ID

public static final OptionID DISTANCE_FUNCTION_ID
OptionID for DISTANCE_FUNCTION_PARAM


DISTANCE_FUNCTION_PARAM

public final ClassParameter<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: materialize.distance


distanceFunction

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


materialized

protected HashMap<Integer,List<DistanceResultPair<D extends Distance<D>>>> materialized
Materialized neighborhood

Constructor Detail

MaterializeKNNPreprocessor

public MaterializeKNNPreprocessor()
Provides a k nearest neighbors Preprocessor.

Method Detail

run

public void run(Database<O> database,
                boolean verbose,
                boolean time)
Annotates the nearest neighbors based on the values of k 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

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Sets the parameter values of K_PARAM and DISTANCE_FUNCTION_PARAM to k and distanceFunction, respectively.

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

shortDescription

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

Specified by:
shortDescription in interface Parameterizable
Overrides:
shortDescription in class AbstractParameterizable
Returns:
Description of the class

getMaterialized

public HashMap<Integer,List<DistanceResultPair<D>>> getMaterialized()
Materialize a neighborhood.

Returns:
the materialized neighborhoods

Release 0.2 (2009-07-06_1820)