Documentation of 'jsat.linear.distancemetrics.DenseSparseMetric' Java class
DenseSparseMetric
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. A DistanceMetric that 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 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 for Vec.isSparse(), the distance will be calculated using DistanceMetric.dist(jsat.linear.Vec, jsat.linear.Vec) instead.
        Parameters:
        summaryConst - the summary constant for the main vector obtained with getVectorConstant(jsat.linear.Vec)
        main - the main vector the summary constant is for
        target - 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

You see the box below because you did not login.