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

Class NormalizedEuclideanDistance

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


    public class NormalizedEuclideanDistance
    extends TrainableDistanceMetric
    Implementation of the Normalized Euclidean Distance Metric. The normalized version divides each variable by its standard deviation, and then continues as the normal EuclideanDistance.
    The same results can be achieved by first applying UnitVarianceTransform to a data set before using the L2 norm.
    It is equivalent to the MahalanobisDistance if only the diagonal values were used.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      NormalizedEuclideanDistance()
      Creates a new Normalized Euclidean distance metric
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      NormalizedEuclideanDistance clone() 
      double dist(int a, int b, java.util.List<? extends Vec> vecs, java.util.List<java.lang.Double> cache)
      Computes the distance between 2 vectors in the original list of vectors.
      double dist(int a, Vec b, java.util.List<? extends Vec> vecs, java.util.List<java.lang.Double> cache)
      Computes the distance between one vector in the original list of vectors with that of another vector not from the original list.
      double dist(int a, Vec b, java.util.List<java.lang.Double> qi, java.util.List<? extends Vec> vecs, java.util.List<java.lang.Double> cache)
      Computes the distance between one vector in the original list of vectors with that of another vector not from the original list, but had information generated by DistanceMetric.getQueryInfo(jsat.linear.Vec).
      double dist(Vec a, Vec b)
      Computes the distance between 2 vectors.
      java.util.List<java.lang.Double> getAccelerationCache(java.util.List<? extends Vec> vecs, boolean parallel)
      Returns a cache of double values associated with the given list of vectors in the given order.
      java.util.List<java.lang.Double> getQueryInfo(Vec q)
      Pre computes query information that would have be generated if the query was a member of the original list of vectors when calling DistanceMetric.getAccelerationCache(java.util.List) .
      boolean isIndiscemible()
      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
      boolean isSubadditive()
      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)
      boolean isSymmetric()
      Returns true if this distance metric obeys the rule that, for any x, y, and z ∈ S
      d(x, y) = d(y, x)
      double metricBound()
      All metrics must return values greater than or equal to 0.
      boolean needsTraining()
      Returns true if the metric needs to be trained.
      boolean supportsAcceleration()
      Indicates if this distance metric supports building an acceleration cache using the DistanceMetric.getAccelerationCache(java.util.List) and associated distance methods.
      boolean supportsClassificationTraining()
      Some metrics might be special purpose, and not trainable for all types of data sets or tasks.
      boolean supportsRegressionTraining()
      Some metrics might be special purpose, and not trainable for all types of data sets tasks.
      void train(ClassificationDataSet dataSet)
      Trains this metric on the given classification problem data set
      void train(ClassificationDataSet dataSet, boolean parallel)
      Trains this metric on the given classification problem data set
      void train(DataSet dataSet)
      Trains this metric on the given data set
      void train(DataSet dataSet, boolean parallel)
      Trains this metric on the given data set
      <V extends Vec>
      void
      train(java.util.List<V> dataSet)
      Trains this metric on the given data set
      <V extends Vec>
      void
      train(java.util.List<V> dataSet, boolean parallel)
      Trains this metric on the given data set
      void train(RegressionDataSet dataSet)
      Trains this metric on the given regression problem data set
      void train(RegressionDataSet dataSet, boolean parallel)
      Trains this metric on the given regression problem data set
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NormalizedEuclideanDistance

        public NormalizedEuclideanDistance()
        Creates a new Normalized Euclidean distance metric
    • Method Detail

      • train

        public <V extends Vec> void train(java.util.List<V> dataSet)
        Description copied from class: TrainableDistanceMetric
        Trains this metric on the given data set
        Overrides:
        train in class TrainableDistanceMetric
        Type Parameters:
        V - the type of vectors in the list
        Parameters:
        dataSet - the data set to train on
      • train

        public <V extends Vec> void train(java.util.List<V> dataSet,
                                          boolean parallel)
        Description copied from class: TrainableDistanceMetric
        Trains this metric on the given data set
        Specified by:
        train in class TrainableDistanceMetric
        Type Parameters:
        V - the type of vectors in the list
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used for training. false if it should be done in a single-threaded manner.
      • train

        public void train(DataSet dataSet,
                          boolean parallel)
        Description copied from class: TrainableDistanceMetric
        Trains this metric on the given data set
        Specified by:
        train in class TrainableDistanceMetric
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used for training. false if it should be done in a single-threaded manner.
      • train

        public void train(ClassificationDataSet dataSet,
                          boolean parallel)
        Description copied from class: TrainableDistanceMetric
        Trains this metric on the given classification problem data set
        Specified by:
        train in class TrainableDistanceMetric
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used for training. false if it should be done in a single-threaded manner.
      • supportsClassificationTraining

        public boolean supportsClassificationTraining()
        Description copied from class: TrainableDistanceMetric
        Some metrics might be special purpose, and not trainable for all types of data sets or tasks. This method returns true if this metric supports training for classification problems, and false if it does not.
        If a metric can learn from unlabeled data, it must return true for this method.
        Specified by:
        supportsClassificationTraining in class TrainableDistanceMetric
        Returns:
        true if this metric supports training for classification problems, and false if it does not
      • train

        public void train(RegressionDataSet dataSet,
                          boolean parallel)
        Description copied from class: TrainableDistanceMetric
        Trains this metric on the given regression problem data set
        Specified by:
        train in class TrainableDistanceMetric
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used for training. false if it should be done in a single-threaded manner.
      • supportsRegressionTraining

        public boolean supportsRegressionTraining()
        Description copied from class: TrainableDistanceMetric
        Some metrics might be special purpose, and not trainable for all types of data sets tasks. This method returns true if this metric supports training for regression problems, and false if it does not.
        If a metric can learn from unlabeled data, it must return true for this method.
        Specified by:
        supportsRegressionTraining in class TrainableDistanceMetric
        Returns:
        true if this metric supports training for regression problems, and false if it does not
      • needsTraining

        public boolean needsTraining()
        Description copied from class: TrainableDistanceMetric
        Returns true if the metric needs to be trained. This may be false if the metric allows the parameters to be specified beforehand. If the information was specified before hand, or does not need training, false is returned.
        Specified by:
        needsTraining in class TrainableDistanceMetric
        Returns:
        true if the metric needs training, false if it does not.
      • 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.
        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)
        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)
        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
        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.
        Returns:
        the maximal distance for any two points in that could exist by this distance metric.
      • getAccelerationCache

        public java.util.List<java.lang.Double> getAccelerationCache(java.util.List<? extends Vec> vecs,
                                                                     boolean parallel)
        Description copied from interface: DistanceMetric
        Returns a cache of double values associated with the given list of vectors in the given order. This can be used by the distance metric to increase runtime at the cost of memory. This is an optional method.
        If this metric does not support acceleration, null will be returned.
        Parameters:
        vecs - the list of vectors to build an acceleration cache for
        parallel - true if multiple threads should be used to perform clustering. false if it should be done in a single threaded manner.
        Returns:
        the list of double for the cache
      • dist

        public double dist(int a,
                           int b,
                           java.util.List<? extends Vec> vecs,
                           java.util.List<java.lang.Double> cache)
        Description copied from interface: DistanceMetric
        Computes the distance between 2 vectors in the original list of vectors.
        If the cache input is null, then DistanceMetric.dist(jsat.linear.Vec, jsat.linear.Vec) will be called directly.
        Parameters:
        a - the index of the first vector
        b - the index of the second vector
        vecs - the list of vectors used to build the cache
        cache - the cache associated with the given list of vectors
        Returns:
        the distance between the two vectors
      • dist

        public double dist(int a,
                           Vec b,
                           java.util.List<? extends Vec> vecs,
                           java.util.List<java.lang.Double> cache)
        Description copied from interface: DistanceMetric
        Computes the distance between one vector in the original list of vectors with that of another vector not from the original list.
        If the cache input is null, then DistanceMetric.dist(jsat.linear.Vec, jsat.linear.Vec) will be called directly.
        Parameters:
        a - the index of the vector in the cache
        b - the other vector
        vecs - the list of vectors used to build the cache
        cache - the cache associated with the given list of vectors
        Returns:
        the distance between the two vectors
      • getQueryInfo

        public java.util.List<java.lang.Double> getQueryInfo(Vec q)
        Description copied from interface: DistanceMetric
        Pre computes query information that would have be generated if the query was a member of the original list of vectors when calling DistanceMetric.getAccelerationCache(java.util.List) . This can then be used if a large number of distance computations are going to be done against points in the original set for a point that is outside the original space.

        If this metric does not support acceleration, null will be returned.
        Parameters:
        q - the query point to generate cache information for
        Returns:
        the cache information for the query point
      • dist

        public double dist(int a,
                           Vec b,
                           java.util.List<java.lang.Double> qi,
                           java.util.List<? extends Vec> vecs,
                           java.util.List<java.lang.Double> cache)
        Description copied from interface: DistanceMetric
        Computes the distance between one vector in the original list of vectors with that of another vector not from the original list, but had information generated by DistanceMetric.getQueryInfo(jsat.linear.Vec).
        If the cache input is null, then DistanceMetric.dist(jsat.linear.Vec, jsat.linear.Vec) will be called directly.
        Parameters:
        a - the index of the vector in the cache
        b - the other vector
        qi - the query information about b
        vecs - the list of vectors used to build the cache
        cache - the cache associated with the given list of vectors
        Returns:
        the distance between the two vectors

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.