jsat.linear.vectorcollection
Interface VectorCollection<V extends Vec>
-
- Type Parameters:
V-
- All Superinterfaces:
- java.lang.Cloneable, java.io.Serializable
- All Known Subinterfaces:
- DualTree<V>, IncrementalCollection<V>
- All Known Implementing Classes:
- BallTree, CoverTree, DefaultVectorCollection, KDTree, RandomBallCover, RandomBallCoverOneShot, RandomProjectionLSH, RTree, SVPTree, VectorArray, VPTree, VPTreeMV
public interface VectorCollection<V extends Vec> extends java.lang.Cloneable, java.io.SerializableA Vector Collection is a collection of vectors that is meant to be used to obtain a subset of the collection via a query vector. A query can be for the nearest neighbors, or for all vectors within a given range.
Different vector collections have different performance properties for both training and execution time.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method and Description default voidbuild(boolean parallel, java.util.List<V> collection)Builds this metric index from the given collection of points using whatever distance metric is currently set for the metric index.voidbuild(boolean parallel, java.util.List<V> collection, DistanceMetric dm)Builds this metric index from the given collection of points using the given distance metric.default voidbuild(java.util.List<V> collection)Builds this metric index from the given collection of points using whatever distance metric is currently set for the metric index.default voidbuild(java.util.List<V> collection, DistanceMetric dm)Builds this metric index from the given collection of points using the given distance metric.VectorCollection<V>clone()Vget(int indx)Accesses a vector from this collection via index.java.util.List<java.lang.Double>getAccelerationCache()DistanceMetricgetDistanceMetric()default java.util.List<Vec>getVecs()default voidsearch(java.util.List<V> Q, double r_min, double r_max, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)default voidsearch(java.util.List<V> Q, int numNeighbors, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)default java.util.List<? extends VecPaired<V,java.lang.Double>>search(Vec query, double range)Deprecated.This API is from the original JSAT interface. It will be removed in the future.voidsearch(Vec query, double range, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)Performs a range search of the current collection.default java.util.List<? extends VecPaired<V,java.lang.Double>>search(Vec query, int num_neighbors)Deprecated.This API is from the original JSAT interface. It will be removed in the future.voidsearch(Vec query, int numNeighbors, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)Performs k-Nearest Neighbor search of the current collection.default voidsearch(VectorCollection<V> Q, double r_min, double r_max, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)default voidsearch(VectorCollection<V> Q, int numNeighbors, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)voidsetDistanceMetric(DistanceMetric dm)Sets the distance metric used for this collection.intsize()Returns the number of vectors stored in the collection
-
-
-
Method Detail
-
build
default void build(java.util.List<V> collection)
Builds this metric index from the given collection of points using whatever distance metric is currently set for the metric index.- Parameters:
collection- the list of vectors to put into the index
-
build
default void build(java.util.List<V> collection, DistanceMetric dm)
Builds this metric index from the given collection of points using the given distance metric.- Parameters:
collection- the list of vectors to put into the indexdm- the distance metric to build the index using.
-
build
default void build(boolean parallel, java.util.List<V> collection)Builds this metric index from the given collection of points using whatever distance metric is currently set for the metric index.- Parameters:
parallel-trueif the index should be built in parallel, orfalseif it should be done in a single thread.collection- the list of vectors to put into the index
-
build
void build(boolean parallel, java.util.List<V> collection, DistanceMetric dm)Builds this metric index from the given collection of points using the given distance metric.- Parameters:
parallel-trueif the index should be built in parallel, orfalseif it should be done in a single thread.collection- the list of vectors to put into the indexdm- the distance metric to build the index using.
-
setDistanceMetric
void setDistanceMetric(DistanceMetric dm)
Sets the distance metric used for this collection.- Parameters:
dm- the distance metric to use
-
getDistanceMetric
DistanceMetric getDistanceMetric()
- Returns:
- the distance metric to use
-
search
default java.util.List<? extends VecPaired<V,java.lang.Double>> search(Vec query, double range)
Deprecated. This API is from the original JSAT interface. It will be removed in the future.Searches the space for all vectors that are within a given range of the query vector.- Parameters:
query- the vector we want to find others nearrange- the search range around our query- Returns:
- the list of all vectors within the range of our query. The paired value contains the distance to the query vector.
-
search
default java.util.List<? extends VecPaired<V,java.lang.Double>> search(Vec query, int num_neighbors)
Deprecated. This API is from the original JSAT interface. It will be removed in the future.Searches the space for the k neighbors that are closest to the given query vector- Parameters:
query- the vector we want to find neighbors ofnum_neighbors- the maximum number of neighbors to return- Returns:
- the list the k nearest neighbors, in sorted order from closest to farthest. The paired value contains the distance to the query vector
-
search
void search(Vec query, double range, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)
Performs a range search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.- Parameters:
query- the point to search for the neighbors within a given radius.range- the radius to search for all the neighbors with a distance ≤ range.neighbors- the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.distances- the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
-
search
void search(Vec query, int numNeighbors, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)
Performs k-Nearest Neighbor search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.- Parameters:
query- the point to search for the k-nearest neighbors ofnumNeighbors- the number of neighbors k to search for.neighbors- the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.distances- the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
-
get
V get(int indx)
Accesses a vector from this collection via index.- Parameters:
indx- the index in [0,size()) of the vector to access- Returns:
- the vector from the collection
-
getAccelerationCache
java.util.List<java.lang.Double> getAccelerationCache()
-
size
int size()
Returns the number of vectors stored in the collection- Returns:
- the size of the collection
-
search
default void search(java.util.List<V> Q, double r_min, double r_max, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)
-
search
default void search(VectorCollection<V> Q, double r_min, double r_max, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)
-
search
default void search(java.util.List<V> Q, int numNeighbors, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)
-
search
default void search(VectorCollection<V> Q, int numNeighbors, java.util.List<java.util.List<java.lang.Integer>> neighbors, java.util.List<java.util.List<java.lang.Double>> distances, boolean parallel)
-
clone
VectorCollection<V> clone()
-
getVecs
default java.util.List<Vec> getVecs()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG