Documentation of 'jsat.linear.distancemetrics.PearsonDistance' Java class
PearsonDistance
jsat.linear.distancemetrics

Class PearsonDistance

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, DistanceMetric


    public class PearsonDistance
    extends java.lang.Object
    implements DistanceMetric
    A valid distance metric formed from the Pearson Correlation between two vectors. The distance in the range of [0, 1].
    See Also:
    Serialized Form
    • Constructor Detail

      • PearsonDistance

        public PearsonDistance()
        Creates a new standard Pearson Distance that does not ignore zero values and anti-correlated values are considered far away.
      • PearsonDistance

        public PearsonDistance(boolean bothNonZero,
                               boolean absoluteDistance)
        Creates a new Pearson Distance object
        Parameters:
        bothNonZero - true if non zero values should be treated as "missing" or "no vote", and will not contribute. But this will not change the mean value used. false produces the standard Pearson value.
        absoluteDistance - true to use the absolute correlation, meaning correlated and anti-correlated values will have the same distance.
    • Method Detail

      • dist

        public double dist(Vec a,
                           Vec b)
        Description copied from interface: DistanceMetric
        Computes the distance between 2 vectors. The smaller the value, the closer, and there for, more similar, the vectors are. 0 indicates the vectors are the same.
        Specified by:
        dist in interface DistanceMetric
        Parameters:
        a - the first vector
        b - the second vector
        Returns:
        the distance between them
      • isSymmetric

        public boolean isSymmetric()
        Description copied from interface: DistanceMetric
        Returns true if this distance metric obeys the rule that, for any x, y, and z ∈ S
        d(x, y) = d(y, x)
        Specified by:
        isSymmetric in interface DistanceMetric
        Returns:
        true if this distance metric is symmetric, false if it is not
      • isSubadditive

        public boolean isSubadditive()
        Description copied from interface: DistanceMetric
        Returns true if this distance metric obeys the rule that, for any x, y, and z ∈ S
        d(x, z) ≤ d(x, y) + d(y, z)
        Specified by:
        isSubadditive in interface DistanceMetric
        Returns:
        true if this distance metric supports the triangle inequality, false if it does not.
      • isIndiscemible

        public boolean isIndiscemible()
        Description copied from interface: DistanceMetric
        Returns true if this distance metric obeys the rule that, for any x and y ∈ S
        d(x, y) = 0 if and only if x = y
        Specified by:
        isIndiscemible in interface DistanceMetric
        Returns:
        true if this distance metric is indicemible, false otherwise.
      • metricBound

        public double metricBound()
        Description copied from interface: DistanceMetric
        All metrics must return values greater than or equal to 0. The upper bound on the value returned is different for different metrics. This method returns the theoretical maximal value that could be returned by this distance metric. That means Double.POSITIVE_INFINITY is a valid return value.
        Specified by:
        metricBound in interface DistanceMetric
        Returns:
        the maximal distance for any two points in that could exist by this distance metric.
      • correlation

        public static double correlation(Vec a,
                                         Vec b,
                                         boolean bothNonZero)
        Computes the Pearson correlation between two vectors. If one of the vectors is all zeros, the result is undefined. In cases where both are zero vectors, 1 will be returned to indicate they are the same. In cases where one of the numerator coefficients is zero, its value will be bumped up to an epsilon to provide a near result.

        In cases where bothNonZero is true, and the vectors have no overlapping non zero values, 0 will be returned.
        Parameters:
        a - the first vector
        b - the second vector
        bothNonZero - false is the normal Pearson correlation. true will make the computation ignore all indexes where one of the values is zero, the mean will be from all non zero values in each vector.
        Returns:
        the Pearson correlation in [-1, 1]

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.