|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.neighborhood.Searcher
org.apache.mahout.math.neighborhood.UpdatableSearcher
org.apache.mahout.math.neighborhood.FastProjectionSearch
public class FastProjectionSearch
Does approximate nearest neighbor search by projecting the vectors similar to ProjectionSearch. The main difference between this class and the ProjectionSearch is the use of sorted arrays instead of binary search trees to implement the sets of scalar projections. Instead of taking log n time to add a vector to each of the vectors, * the pending additions are kept separate and are searched using a brute search. When there are "enough" pending additions, they're committed into the main pool of vectors.
Field Summary |
---|
Fields inherited from class org.apache.mahout.math.neighborhood.Searcher |
---|
distanceMeasure |
Constructor Summary | |
---|---|
FastProjectionSearch(DistanceMeasure distanceMeasure,
int numProjections,
int searchSize)
|
Method Summary | |
---|---|
void |
add(Vector vector)
Add a new Vector to the Searcher that will be checked when getting the nearest neighbors. |
void |
clear()
|
Iterator<Vector> |
iterator()
This iterates on the snapshot of the contents first instantiated regardless of any future modifications. |
boolean |
remove(Vector vector,
double epsilon)
|
List<WeightedThing<Vector>> |
search(Vector query,
int limit)
When querying the Searcher for the closest vectors, a list of WeightedThing |
WeightedThing<Vector> |
searchFirst(Vector query,
boolean differentThanQuery)
Returns the closest vector to the query. |
int |
size()
Returns the number of WeightedVectors being searched for nearest neighbors. |
Methods inherited from class org.apache.mahout.math.neighborhood.Searcher |
---|
addAll, addAllMatrixSlices, addAllMatrixSlicesAsWeightedVectors, getCandidateQueue, getDistanceMeasure, search, searchFirst |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FastProjectionSearch(DistanceMeasure distanceMeasure, int numProjections, int searchSize)
Method Detail |
---|
public void add(Vector vector)
add
in class Searcher
public int size()
size
in class Searcher
public List<WeightedThing<Vector>> search(Vector query, int limit)
search
in class Searcher
query
- the vector to search forlimit
- the number of results to return
public WeightedThing<Vector> searchFirst(Vector query, boolean differentThanQuery)
searchFirst
in class Searcher
query
- the vector to search fordifferentThanQuery
- if true, returns the closest vector different than the query (this
only matters if the query is among the searched vectors), otherwise,
returns the closest vector to the query (even the same vector).
public boolean remove(Vector vector, double epsilon)
remove
in class UpdatableSearcher
public void clear()
clear
in class UpdatableSearcher
public Iterator<Vector> iterator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |