O
- Object type@Reference(authors="W. Dong, C. Moses, K. Li", title="Efficient k-nearest neighbor graph construction for generic similarity measures", booktitle="Proc. 20th Int. Conf. on World Wide Web (WWW\'11)", url="https://doi.org/10.1145/1963405.1963487", bibkey="DBLP:conf/www/DongCL11") public class NNDescent<O> extends AbstractMaterializeKNNPreprocessor<O>
Reference:
W. Dong and C. Moses and K. Li
Efficient k-nearest neighbor graph construction for generic similarity
measures
Proc. 20th Int. Conf. on World Wide Web (WWW'11)
Modifier and Type | Class and Description |
---|---|
static class |
NNDescent.Factory<O>
Index factory.
|
Modifier and Type | Field and Description |
---|---|
private double |
delta
early termination parameter
|
private int |
iterations
maximum number of iterations
|
private static Logging |
LOG
Logger
|
private boolean |
noInitialNeighbors
Do not use initial neighbors
|
private java.lang.String |
prefix
Log prefix.
|
private double |
rho
sample rate
|
private RandomFactory |
rnd
Random generator
|
private WritableDataStore<KNNHeap> |
store
store for neighbors
|
distanceFunction, distanceQuery, k
relation, storage
Constructor and Description |
---|
NNDescent(Relation<O> relation,
DistanceFunction<? super O> distanceFunction,
int k,
RandomFactory rnd,
double delta,
double rho,
boolean noInitialNeighbors,
int iterations)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
add(DBIDRef cur,
DBIDRef cand,
double distance)
Add cand to cur's heap neighbors with distance
|
private void |
addpair(WritableDataStore<HashSetModifiableDBIDs> newNeighbors,
DBIDRef o1,
DBIDRef o2) |
private void |
boundSize(HashSetModifiableDBIDs set,
int items)
Bound the size of a set by random sampling.
|
private void |
clearAll(DBIDs ids,
WritableDataStore<HashSetModifiableDBIDs> sets)
Clear (but reuse) all sets in the given storage.
|
KNNQuery<O> |
getKNNQuery(DistanceQuery<O> distanceQuery,
java.lang.Object... hints)
Get a KNN query object for the given distance query and k.
|
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.
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
void |
logStatistics()
Send statistics to the logger, if enabled.
|
protected void |
preprocess()
Perform the preprocessing step.
|
private int |
processNewNeighbors(WritableDataStore<HashSetModifiableDBIDs> flag,
HashSetModifiableDBIDs newFwd,
HashSetModifiableDBIDs oldFwd,
HashSetModifiableDBIDs newRev,
HashSetModifiableDBIDs oldRev)
Process new neighbors.
|
private void |
reverse(WritableDataStore<HashSetModifiableDBIDs> sampleNewHash,
WritableDataStore<HashSetModifiableDBIDs> newReverseNeighbors,
WritableDataStore<HashSetModifiableDBIDs> oldReverseNeighbors)
calculates new and old neighbors for database
|
private int |
sampleNew(DBIDs ids,
WritableDataStore<HashSetModifiableDBIDs> sampleNewNeighbors,
WritableDataStore<HashSetModifiableDBIDs> newNeighborHash,
int items)
samples newNeighbors for every object
|
createStorage, get, getDistanceQuery, getK, initialize
private static final Logging LOG
private java.lang.String prefix
private final RandomFactory rnd
private double delta
private double rho
private int iterations
private boolean noInitialNeighbors
private WritableDataStore<KNNHeap> store
public NNDescent(Relation<O> relation, DistanceFunction<? super O> distanceFunction, int k, RandomFactory rnd, double delta, double rho, boolean noInitialNeighbors, int iterations)
relation
- Relation to indexdistanceFunction
- distance functionk
- krnd
- Random generatordelta
- Delta thresholdrho
- Rho thresholdnoInitialNeighbors
- Do not use initial neighborsiterations
- Maximum number of iterationsprotected void preprocess()
AbstractMaterializeKNNPreprocessor
preprocess
in class AbstractMaterializeKNNPreprocessor<O>
private void clearAll(DBIDs ids, WritableDataStore<HashSetModifiableDBIDs> sets)
ids
- Ids to processsets
- Sets to clearprivate void boundSize(HashSetModifiableDBIDs set, int items)
set
- Set to processitems
- Maximum sizeprivate int processNewNeighbors(WritableDataStore<HashSetModifiableDBIDs> flag, HashSetModifiableDBIDs newFwd, HashSetModifiableDBIDs oldFwd, HashSetModifiableDBIDs newRev, HashSetModifiableDBIDs oldRev)
flag
- Flags to mark new neighbors.newFwd
- New forward neighborsoldFwd
- Old forward neighborsnewRev
- New reverse neighborsoldRev
- Old reverse neighborsprivate boolean add(DBIDRef cur, DBIDRef cand, double distance)
cur
- Current objectcand
- Neighbor candidatedistance
- Distancetrue
if it was a new neighbor.private void addpair(WritableDataStore<HashSetModifiableDBIDs> newNeighbors, DBIDRef o1, DBIDRef o2)
private int sampleNew(DBIDs ids, WritableDataStore<HashSetModifiableDBIDs> sampleNewNeighbors, WritableDataStore<HashSetModifiableDBIDs> newNeighborHash, int items)
ids
- All idssampleNewNeighbors
- Output of sampled new neighborsnewNeighborHash
- - new neighbors for every objectitems
- Number of items to collectprivate void reverse(WritableDataStore<HashSetModifiableDBIDs> sampleNewHash, WritableDataStore<HashSetModifiableDBIDs> newReverseNeighbors, WritableDataStore<HashSetModifiableDBIDs> oldReverseNeighbors)
sampleNewHash
- new neighbors for every objectnewReverseNeighbors
- new reverse neighborsoldReverseNeighbors
- old reverse neighborsprotected Logging getLogger()
AbstractPreprocessorIndex
getLogger
in class AbstractPreprocessorIndex<O,KNNList>
public void logStatistics()
Index
public java.lang.String getLongName()
Result
public java.lang.String getShortName()
Result
public KNNQuery<O> getKNNQuery(DistanceQuery<O> distanceQuery, java.lang.Object... hints)
KNNIndex
getKNNQuery
in interface KNNIndex<O>
getKNNQuery
in class AbstractMaterializeKNNPreprocessor<O>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
Copyright © 2019 ELKI Development Team. License information.