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

Interface KernelTrick

    • Method Summary

      All Methods Instance Methods Abstract 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.
      KernelTrick clone() 
      double eval(int a, int b, java.util.List<? extends Vec> trainingSet, java.util.List<java.lang.Double> cache)
      Produces the correct kernel evaluation given the training set and the cache generated by getAccelerationCache(List).
      double eval(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 kernel product between one vector in the original list of vectors with that of another vector not from the original list, but had information generated by getQueryInfo(jsat.linear.Vec).
      double eval(Vec a, Vec b)
      Evaluate this kernel function for the two given vectors.
      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 getAccelerationCache(java.util.List) .
      boolean normalized()
      This method indicates if a kernel is a normalized kernel or not.
      boolean supportsAcceleration()
      Indicates if this kernel supports building an acceleration cache using the getAccelerationCache(List) and associated cache accelerated methods.
      java.lang.String toString()
      A descriptive name for the type of KernelFunction
    • Method Detail

      • eval

        double eval(Vec a,
                    Vec b)
        Evaluate this kernel function for the two given vectors.
        Parameters:
        a - the first vector
        b - the first vector
        Returns:
        the evaluation
      • toString

        java.lang.String toString()
        A descriptive name for the type of KernelFunction
        Overrides:
        toString in class java.lang.Object
        Returns:
        a descriptive name for the type of KernelFunction
      • supportsAcceleration

        boolean supportsAcceleration()
        Indicates if this kernel supports building an acceleration cache using the getAccelerationCache(List) and associated cache accelerated methods. By default this method will return false. If true, then a cache can be obtained from this matrix and used in conjunction with eval(int, Vec, List, List, List) and eval(int, int, List, List) to perform kernel products.
        Returns:
        true if cache acceleration is supported for this kernel, false otherwise.
      • getAccelerationCache

        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. If this kernel does not support acceleration, null will be returned.
        Parameters:
        trainingSet - the list of training set vectors
        Returns:
        a list of cache values that may be used by this kernel
      • getQueryInfo

        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 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.
        Parameters:
        q - the query point to generate cache information for
        Returns:
        the cache information for the query point
      • addToCache

        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. 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 getAccelerationCache(java.util.List)

        If this kernel does not support acceleration, this method call will function as a nop.
        Parameters:
        newVec - the new vector to add to the cache values
        cache - the original list of cache values to add to
      • eval

        double eval(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 kernel product between one vector in the original list of vectors with that of another vector not from the original list, but had information generated by getQueryInfo(jsat.linear.Vec).
        If the cache input is null, then eval(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 kernel product of the two vectors
      • eval

        double eval(int a,
                    int b,
                    java.util.List<? extends Vec> trainingSet,
                    java.util.List<java.lang.Double> cache)
        Produces the correct kernel evaluation given the training set and the cache generated by getAccelerationCache(List). The training vectors should be in the same order.
        Parameters:
        a - the index of the first training vector
        b - the index of the second training vector
        trainingSet - the list of training set vectors
        cache - the double list of cache values generated by this kernel for the given training set
        Returns:
        the same kernel evaluation result as eval(jsat.linear.Vec, jsat.linear.Vec)
      • evalSum

        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
        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

        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
        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
      • normalized

        boolean normalized()
        This method indicates if a kernel is a normalized kernel or not. A normalized kernel is one in which k(x,x) = 1 for the same object, and no value greater than 1 can be returned.
        Returns:
        true if this is a normalized kernel. false otherwise.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.