Documentation of 'jsat.distributions.kernels.DistanceMetricBasedKernel' Java class
DistanceMetricBasedKernel
jsat.distributions.kernels

Class DistanceMetricBasedKernel

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, KernelTrick, Parameterized
    Direct Known Subclasses:
    GeneralRBFKernel


    public abstract class DistanceMetricBasedKernel
    extends java.lang.Object
    implements KernelTrick
    This abstract class provides the means of implementing a Kernel based off some DistanceMetric. This will pre-implement most of the methods of the KernelTrick interface, including using the distance acceleration of the metric (if supported) when appropriate.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void addToCache(Vec newVec, java.util.List<java.lang.Double> cache)
      Appends the new cache values for the given vector to the list of cache values.
      abstract KernelTrick clone() 
      double evalSum(java.util.List<? extends Vec> finalSet, java.util.List<java.lang.Double> cache, double[] alpha, Vec y, int start, int end)
      Performs an efficient summation of kernel products of the form
      αi k(xi, y)
      where x are the final set of vectors, and α the associated scalar multipliers
      double evalSum(java.util.List<? extends Vec> finalSet, java.util.List<java.lang.Double> cache, double[] alpha, Vec y, java.util.List<java.lang.Double> qi, int start, int end)
      Performs an efficient summation of kernel products of the form
      αi k(xi, y)
      where x are the final set of vectors, and α the associated scalar multipliers
      java.util.List<java.lang.Double> getAccelerationCache(java.util.List<? extends Vec> trainingSet)
      Creates a new list cache values from a given list of training set vectors.
      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 KernelTrick.getAccelerationCache(java.util.List) .
      boolean supportsAcceleration()
      Indicates if this kernel supports building an acceleration cache using the KernelTrick.getAccelerationCache(List) and associated cache accelerated methods.
      • Methods inherited from class java.lang.Object

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

      • DistanceMetricBasedKernel

        public DistanceMetricBasedKernel(DistanceMetric d)
        Creates a new distance based kerenel
        Parameters:
        d - the distance metric to use
    • Method Detail

      • clone

        public abstract KernelTrick clone()
        Specified by:
        clone in interface KernelTrick
        Overrides:
        clone in class java.lang.Object
      • getAccelerationCache

        public java.util.List<java.lang.Double> getAccelerationCache(java.util.List<? extends Vec> trainingSet)
        Description copied from interface: KernelTrick
        Creates a new list cache values from a given list of training set vectors. If this kernel does not support acceleration, null will be returned.
        Specified by:
        getAccelerationCache in interface KernelTrick
        Parameters:
        trainingSet - the list of training set vectors
        Returns:
        a list of cache values that may be used by this kernel
      • getQueryInfo

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

        If this kernel does not support acceleration, null will be returned.
        Specified by:
        getQueryInfo in interface KernelTrick
        Parameters:
        q - the query point to generate cache information for
        Returns:
        the cache information for the query point
      • addToCache

        public void addToCache(Vec newVec,
                               java.util.List<java.lang.Double> cache)
        Description copied from interface: KernelTrick
        Appends the new cache values for the given vector to the list of cache values. This method is present for online style kernel learning algorithms, where the set of vectors is not known in advance. When a vector is added to the set of kernel vectors, its cache values can be added using this method.

        The results of calling this sequentially on a lit of vectors starting with an empty double list is equivalent to getting the results from calling KernelTrick.getAccelerationCache(java.util.List)

        If this kernel does not support acceleration, this method call will function as a nop.
        Specified by:
        addToCache in interface KernelTrick
        Parameters:
        newVec - the new vector to add to the cache values
        cache - the original list of cache values to add to
      • evalSum

        public double evalSum(java.util.List<? extends Vec> finalSet,
                              java.util.List<java.lang.Double> cache,
                              double[] alpha,
                              Vec y,
                              int start,
                              int end)
        Description copied from interface: KernelTrick
        Performs an efficient summation of kernel products of the form
        αi k(xi, y)
        where x are the final set of vectors, and α the associated scalar multipliers
        Specified by:
        evalSum in interface KernelTrick
        Parameters:
        finalSet - the final set of vectors
        cache - the cache associated with the final set of vectors
        alpha - the coefficients associated with each vector
        y - the vector to perform the summed kernel products against
        start - the starting index (inclusive) to sum from
        end - the ending index (exclusive) to sum from
        Returns:
        the sum of the multiplied kernel products
      • evalSum

        public double evalSum(java.util.List<? extends Vec> finalSet,
                              java.util.List<java.lang.Double> cache,
                              double[] alpha,
                              Vec y,
                              java.util.List<java.lang.Double> qi,
                              int start,
                              int end)
        Description copied from interface: KernelTrick
        Performs an efficient summation of kernel products of the form
        αi k(xi, y)
        where x are the final set of vectors, and α the associated scalar multipliers
        Specified by:
        evalSum in interface KernelTrick
        Parameters:
        finalSet - the final set of vectors
        cache - the cache associated with the final set of vectors
        alpha - the coefficients associated with each vector
        y - the vector to perform the summed kernel products against
        qi - the query information about y
        start - the starting index (inclusive) to sum from
        end - the ending index (exclusive) to sum from
        Returns:
        the sum of the multiplied kernel products

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.