Package elki.index.preprocessed.knn
Class NaiveProjectedKNNPreprocessor<O extends NumberVector>
- java.lang.Object
-
- elki.index.preprocessed.knn.NaiveProjectedKNNPreprocessor<O>
-
@Reference(authors="Erich Schubert, Arthur Zimek, Hans-Peter Kriegel", title="Fast and Scalable Outlier Detection with Approximate Nearest Neighbor Ensembles", booktitle="Proc. 20th Int. Conf. Database Systems for Advanced Applications (DASFAA 2015)", url="https://doi.org/10.1007/978-3-319-18123-3_2", bibkey="DBLP:conf/dasfaa/SchubertZK15") public class NaiveProjectedKNNPreprocessor<O extends NumberVector> extends java.lang.Object implements KNNIndex<O>
Compute the approximate k nearest neighbors using 1 dimensional projections.This serves as a comparison method in:
Erich Schubert, Arthur Zimek, Hans-Peter Kriegel
Fast and Scalable Outlier Detection with Approximate Nearest Neighbor Ensembles
Proc. 20th Int. Conf. Database Systems for Advanced Applications (DASFAA 2015)- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNaiveProjectedKNNPreprocessor.Factory<V extends NumberVector>Index factory classprotected classNaiveProjectedKNNPreprocessor.NaiveProjectedKNNQueryKNN Query processor for naive projections.
-
Field Summary
Fields Modifier and Type Field Description private static LoggingLOGClass logger.(package private) MeanmeanMean number of distance computations.(package private) WritableDataStore<int[]>positionsCurve position storage(package private) RandomProjectionFamilyprojRandom projection family to use.(package private) java.util.List<ModifiableDoubleDBIDList>projectedProjected data.(package private) intprojectionsNumber of projections to use.(package private) java.util.RandomrandomRandom number generator.protected Relation<O>relationThe representation we are bound to.(package private) doublewindowCurve window size.
-
Constructor Summary
Constructors Constructor Description NaiveProjectedKNNPreprocessor(Relation<O> relation, double window, int projections, RandomProjectionFamily proj, java.util.Random random)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinitialize()Initialize the index.KNNSearcher<DBIDRef>kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.KNNSearcher<O>kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.voidlogStatistics()Send statistics to the logger, if enabled.protected voidpreprocess()static int[]randomPermutation(int[] out, java.util.Random random)Perform a random permutation of the array, in-place.static int[]range(int start, int end)Initialize an integer value range.
-
-
-
Field Detail
-
relation
protected final Relation<O extends NumberVector> relation
The representation we are bound to.
-
LOG
private static final Logging LOG
Class logger.
-
window
final double window
Curve window size.
-
projections
final int projections
Number of projections to use.
-
positions
WritableDataStore<int[]> positions
Curve position storage
-
mean
Mean mean
Mean number of distance computations.
-
proj
RandomProjectionFamily proj
Random projection family to use.
-
random
java.util.Random random
Random number generator.
-
projected
java.util.List<ModifiableDoubleDBIDList> projected
Projected data.
-
-
Constructor Detail
-
NaiveProjectedKNNPreprocessor
public NaiveProjectedKNNPreprocessor(Relation<O> relation, double window, int projections, RandomProjectionFamily proj, java.util.Random random)
Constructor.- Parameters:
relation- Relation to index.window- Window multiplicator.projections- Number of projections to use.proj- Projection family to use.random- Random number generator.
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:IndexInitialize the index. For static indexes, this is the moment the index is bulk loaded.- Specified by:
initializein interfaceIndex
-
preprocess
protected void preprocess()
-
range
public static int[] range(int start, int end)Initialize an integer value range.- Parameters:
start- Starting valueend- End value (exclusive)- Returns:
- Array of integers start..end, excluding end.
-
randomPermutation
public static int[] randomPermutation(int[] out, java.util.Random random)Perform a random permutation of the array, in-place. Knuth / Fisher-Yates style shuffle- Parameters:
out- Prefilled array to be modified.random- Random generator.- Returns:
- Same array.
-
logStatistics
public void logStatistics()
Description copied from interface:IndexSend statistics to the logger, if enabled.Note: you must have set the logging level appropriately before initializing the index! Otherwise, the index might not have collected the desired statistics.
- Specified by:
logStatisticsin interfaceIndex
-
kNNByObject
public KNNSearcher<O> kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
kNNByObjectin interfaceKNNIndex<O extends NumberVector>- Parameters:
distanceQuery- Distance querymaxk- Maximum value of kflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
kNNByDBID
public KNNSearcher<DBIDRef> kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
kNNByDBIDin interfaceKNNIndex<O extends NumberVector>- Parameters:
distanceQuery- Distance querymaxk- Maximum value of kflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
-