jsat.linear.distancemetrics
Interface DenseSparseMetric
-
- All Superinterfaces:
- java.lang.Cloneable, DistanceMetric, java.io.Serializable
- All Known Implementing Classes:
- EuclideanDistance, ManhattanDistance, MinkowskiDistance
public interface DenseSparseMetric extends DistanceMetric
Many algorithms require computing the distances from a small set of points to many other points. In these scenarios, if the small set of points contain dense vectors - and the large set contain sparse vectors, a large amount of unnecessary computation may be done. ADistanceMetricthat implements this interface indicates that it supports more efficient computation of the distances in these scenarios.
A distance metric that can efficiently handle dense to sparse distance computations has no reason to implement this interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description doubledist(double summaryConst, Vec main, Vec target)Efficiently computes the distance from one main vector that is used many times, to some sparse target vector.doublegetVectorConstant(Vec vec)Computes a summary constant value for the vector that is based on the distance metric in use.-
Methods inherited from interface jsat.linear.distancemetrics.DistanceMetric
clone, dist, dist, dist, dist, getAccelerationCache, getAccelerationCache, getQueryInfo, isIndiscemible, isSubadditive, isSymmetric, isValidMetric, metricBound, supportsAcceleration, toString
-
-
-
-
Method Detail
-
getVectorConstant
double getVectorConstant(Vec vec)
Computes a summary constant value for the vector that is based on the distance metric in use. This value will be used to perform efficient dense to sparse computations.- Parameters:
vec- the vector that will be used in many distance computations- Returns:
- the summary value for the vector
-
dist
double dist(double summaryConst, Vec main, Vec target)Efficiently computes the distance from one main vector that is used many times, to some sparse target vector. If the target vector dose not return true forVec.isSparse(), the distance will be calculated usingDistanceMetric.dist(jsat.linear.Vec, jsat.linear.Vec)instead.- Parameters:
summaryConst- the summary constant for the main vector obtained withgetVectorConstant(jsat.linear.Vec)main- the main vector the summary constant is fortarget- the target vector to compute the distance to- Returns:
- the distance between the two vectors dist(main, target)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG