O - the type of database objects the preprocessor can be applied to@Title(value="Shared Nearest Neighbor Preprocessor") @Description(value="Computes the k nearest neighbors of objects of a certain database.") public class SharedNearestNeighborPreprocessor<O> extends AbstractPreprocessorIndex<O,ArrayDBIDs> implements SharedNearestNeighborIndex<O>
The k nearest neighbors are assigned based on an arbitrary distance function.
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
SharedNearestNeighborPreprocessor.Factory<O>
Factory class
|
| Modifier and Type | Field and Description |
|---|---|
protected DistanceFunction<O> |
distanceFunction
Hold the distance function to be used.
|
private static Logging |
LOG
Get a logger for this class.
|
protected int |
numberOfNeighbors
Holds the number of nearest neighbors to be used.
|
relation, storage| Constructor and Description |
|---|
SharedNearestNeighborPreprocessor(Relation<O> relation,
int numberOfNeighbors,
DistanceFunction<O> distanceFunction)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Logging |
getLogger()
Get the classes static logger.
|
java.lang.String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
ArrayDBIDs |
getNearestNeighborSet(DBIDRef objid)
Get the precomputed nearest neighbors
|
int |
getNumberOfNeighbors()
Get the number of neighbors
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
void |
initialize()
Initialize the index.
|
void |
logStatistics()
Send statistics to the logger, if enabled.
|
private static final Logging LOG
protected int numberOfNeighbors
protected DistanceFunction<O> distanceFunction
public SharedNearestNeighborPreprocessor(Relation<O> relation, int numberOfNeighbors, DistanceFunction<O> distanceFunction)
relation - Database to usenumberOfNeighbors - Number of neighborsdistanceFunction - Distance functionpublic void initialize()
Indexinitialize in interface Indexpublic ArrayDBIDs getNearestNeighborSet(DBIDRef objid)
SharedNearestNeighborIndexgetNearestNeighborSet in interface SharedNearestNeighborIndex<O>objid - Object IDprotected Logging getLogger()
AbstractPreprocessorIndexgetLogger in class AbstractPreprocessorIndex<O,ArrayDBIDs>public java.lang.String getLongName()
ResultgetLongName in interface Resultpublic java.lang.String getShortName()
ResultgetShortName in interface Resultpublic void logStatistics()
IndexlogStatistics in interface Indexpublic int getNumberOfNeighbors()
getNumberOfNeighbors in interface SharedNearestNeighborIndex<O>Copyright © 2019 ELKI Development Team. License information.