O
- the type of database objects the preprocessor can be applied toD
- the type of distance the used distance function will return@Title(value="Shared nearest neighbor Preprocessor") @Description(value="Computes the k nearest neighbors of objects of a certain database.") public class SharedNearestNeighborPreprocessor<O,D extends Distance<D>> extends AbstractPreprocessorIndex<O,ArrayDBIDs> implements SharedNearestNeighborIndex<O>
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,D extends Distance<D>>
Factory class
|
Modifier and Type | Field and Description |
---|---|
protected DistanceFunction<O,D> |
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.
|
storage
relation
Constructor and Description |
---|
SharedNearestNeighborPreprocessor(Relation<O> relation,
int numberOfNeighbors,
DistanceFunction<O,D> distanceFunction)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Logging |
getLogger()
Get the classes static logger.
|
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
|
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,D extends Distance<D>> distanceFunction
public SharedNearestNeighborPreprocessor(Relation<O> relation, int numberOfNeighbors, DistanceFunction<O,D> distanceFunction)
relation
- Database to usenumberOfNeighbors
- Number of neighborsdistanceFunction
- Distance functionpublic void initialize()
Index
initialize
in interface Index
public ArrayDBIDs getNearestNeighborSet(DBIDRef objid)
SharedNearestNeighborIndex
getNearestNeighborSet
in interface SharedNearestNeighborIndex<O>
objid
- Object IDprotected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class AbstractPreprocessorIndex<O,ArrayDBIDs>
public String getLongName()
Result
getLongName
in interface Result
getLongName
in class AbstractIndex<O>
public String getShortName()
Result
getShortName
in interface Result
getShortName
in class AbstractIndex<O>
public void logStatistics()
Index
logStatistics
in interface Index
public int getNumberOfNeighbors()
getNumberOfNeighbors
in interface SharedNearestNeighborIndex<O>