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

Class KernelPoints



  • public class KernelPoints
    extends java.lang.Object
    This class represents a list of KernelPoint objects. This is done to avoid excessive memory duplication that can occur when multiple KernelPoints are in use at the same time.
    • Constructor Summary

      Constructors 
      Constructor and Description
      KernelPoints(KernelPoints toCopy)
      Copy constructor
      KernelPoints(KernelTrick k, int points, double errorTolerance)
      Creates a new set of kernel points that uses one unified gram matrix for each KernelPoint
      KernelPoints(KernelTrick k, int points, double errorTolerance, boolean mergeGrams)
      Creates a new set of kernel points
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addNewKernelPoint()
      Adds a new Kernel Point to the internal list this object represents.
      KernelPoints clone() 
      double dist(int k, KernelPoint x)
      Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the given KernelPoint
      double dist(int k, KernelPoints X, int j)
      Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the j'th KernelPoint in the given set
      double dist(int k, Vec x, java.util.List<java.lang.Double> qi)
      Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the given vector
      double dot(int k, KernelPoint x)
      Computes the dot product between the k'th KernelPoint and the given KernelPoint
      double dot(int k, KernelPoints X, int j)
      Computes the dot product between the k'th KernelPoint and the j'th KernelPoint in the given set of points.
      double dot(int k, Vec x, java.util.List<java.lang.Double> qi)
      Computes the dot product between the k'th KernelPoint and the given vector in the kernel space.
      double[] dot(Vec x, java.util.List<java.lang.Double> qi)
      Computes the dot product between each KernelPoint in this set and the given vector in the kernel space.
      int getBasisSize()
      Returns the number of basis vectors in use.
      KernelPoint.BudgetStrategy getBudgetStrategy()
      Returns the budget method used
      double getErrorTolerance()
      Returns the error tolerance that is used depending on the KernelPoint.BudgetStrategy in use
      KernelTrick getKernel() 
      int getMaxBudget()
      Returns the current maximum budget for support vectors
      java.util.List<Vec> getRawBasisVecs()
      Returns a list of the raw vectors being used by the kernel points.
      double getSqrdNorm(int k)
      Returns the squared 2 norm value of the k'th KernelPoint
      void mutableAdd(int k, double c, Vec x_t, java.util.List<java.lang.Double> qi)
      Alters ones of the KernelPoint objects by adding / subtracting a vector from it
      void mutableAdd(Vec x_t, Vec cs, java.util.List<java.lang.Double> qi)
      Alters some of the KernelPoints by adding / subtracting a vector from it
      void mutableMultiply(double c)
      Alters all the KernelPoint objects contained in this set by the same constant value
      void mutableMultiply(int k, double c)
      Alters the k'th KernelPoint by multiplying it with a constant value
      void setBudgetStrategy(KernelPoint.BudgetStrategy budgetStrategy)
      Sets the method used for maintaining the budget of support vectors.
      void setErrorTolerance(double errorTolerance)
      Sets the error tolerance used for projection maintenance strategies such as KernelPoint.BudgetStrategy.PROJECTION
      void setMaxBudget(int maxBudget)
      Sets the maximum budget for support vectors to allow.
      int size()
      Returns the number of KernelPoints stored in this set
      • Methods inherited from class java.lang.Object

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

      • KernelPoints

        public KernelPoints(KernelTrick k,
                            int points,
                            double errorTolerance)
        Creates a new set of kernel points that uses one unified gram matrix for each KernelPoint
        Parameters:
        k - the kernel trick to use in which to represent a vector in the kernel space
        points - the initial number of kernel points to store in this set
        errorTolerance - the maximum error allowed for projecting a vector instead of adding it to the basis set
      • KernelPoints

        public KernelPoints(KernelTrick k,
                            int points,
                            double errorTolerance,
                            boolean mergeGrams)
        Creates a new set of kernel points
        Parameters:
        k - the kernel trick to use in which to represent a vector in the kernel space
        points - the initial number of kernel points to store in this set
        errorTolerance - the maximum error allowed for projecting a vector instead of adding it to the basis set
        mergeGrams - whether or not to merge the gram matrices of each KernelPoint.
      • KernelPoints

        public KernelPoints(KernelPoints toCopy)
        Copy constructor
        Parameters:
        toCopy - the object to copy
    • Method Detail

      • setBudgetStrategy

        public void setBudgetStrategy(KernelPoint.BudgetStrategy budgetStrategy)
        Sets the method used for maintaining the budget of support vectors. This method must be called before any vectors are added to the KernelPoint.

        The budget maintenance strategy used controls the time complexity and memory use of the model.
        Parameters:
        budgetStrategy - the budget maintenance strategy
      • getBudgetStrategy

        public KernelPoint.BudgetStrategy getBudgetStrategy()
        Returns the budget method used
        Returns:
        the budget method used
      • setErrorTolerance

        public void setErrorTolerance(double errorTolerance)
        Sets the error tolerance used for projection maintenance strategies such as KernelPoint.BudgetStrategy.PROJECTION
        Parameters:
        errorTolerance - the error tolerance in [0, 1]
      • getErrorTolerance

        public double getErrorTolerance()
        Returns the error tolerance that is used depending on the KernelPoint.BudgetStrategy in use
        Returns:
        the error tolerance value
      • setMaxBudget

        public void setMaxBudget(int maxBudget)
        Sets the maximum budget for support vectors to allow. Setting to Integer.MAX_VALUE is essentially an unbounded number of support vectors. Increasing the budget after adding the first vector is always allowed, but it may not be possible to reduce the number of current support vectors is above the desired budget.
        Parameters:
        maxBudget - the maximum number of allowed support vectors
      • getMaxBudget

        public int getMaxBudget()
        Returns the current maximum budget for support vectors
        Returns:
        the maximum budget for support vectors
      • getSqrdNorm

        public double getSqrdNorm(int k)
        Returns the squared 2 norm value of the k'th KernelPoint
        Parameters:
        k - the KernelPoint to get the norm of
        Returns:
        the squared 2 norm of the k'th KernelPoint
      • dot

        public double dot(int k,
                          Vec x,
                          java.util.List<java.lang.Double> qi)
        Computes the dot product between the k'th KernelPoint and the given vector in the kernel space.
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        x - the vector to contribute to the dot product
        qi - the query information for the vector, or null only if the kernel in use does not support acceleration.
        Returns:
        the dot product between the k'th KernelPoint and the given vector
      • dot

        public double[] dot(Vec x,
                            java.util.List<java.lang.Double> qi)
        Computes the dot product between each KernelPoint in this set and the given vector in the kernel space. The results are equivalent to an array and setting each value using dot(int, jsat.linear.Vec, java.util.List)
        This method should be faster than computing the dot products individual since it avoids redundant kernel computations
        Parameters:
        x - the vector to contribute to the dot product
        qi - the query information for the vector, or null only if the kernel in use does not support acceleration.
        Returns:
        an array where the i'th index contains the dot product of the i'th KernelPoint and the given vector
      • dot

        public double dot(int k,
                          KernelPoint x)
        Computes the dot product between the k'th KernelPoint and the given KernelPoint
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        x - the other KernelPoint to contribute to the dot product
        Returns:
        the dot product between the k'th KernelPoint and the given KernelPoint
      • dot

        public double dot(int k,
                          KernelPoints X,
                          int j)
        Computes the dot product between the k'th KernelPoint and the j'th KernelPoint in the given set of points.
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        X - the other set of KernelPoints
        j - the index of the KernelPoint in the given set to contribute to the dot product
        Returns:
        the dot product between the k'th KernelPoint and the j'th KernelPoint in the given set
      • dist

        public double dist(int k,
                           Vec x,
                           java.util.List<java.lang.Double> qi)
        Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the given vector
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        x - the point to get the Euclidean distance to
        qi - the query information for the vector, or null only if the kernel in use does not support acceleration.
        Returns:
        the Euclidean distance between the k'th KernelPoint and x in the kernel space
      • dist

        public double dist(int k,
                           KernelPoint x)
        Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the given KernelPoint
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        x - the kernel point to get the Euclidean distance to
        Returns:
        the Euclidean distance between the k'th KernelPoint and x in the kernel space
      • dist

        public double dist(int k,
                           KernelPoints X,
                           int j)
        Computes the Euclidean distance in the kernel space between the k'th KernelPoint and the j'th KernelPoint in the given set
        Parameters:
        k - the index of the KernelPoint in this set to contribute to the dot product
        X - the other set of kernel points to obtain the target KernelPoint
        j - the index of the KernelPoint in the given set to contribute to the dot product
        Returns:
        the Euclidean distance between the k'th KernelPoint and the j'th KernelPoint in the other set
      • mutableMultiply

        public void mutableMultiply(int k,
                                    double c)
        Alters the k'th KernelPoint by multiplying it with a constant value
        Parameters:
        k - the index of the KernelPoint to modify
        c - the constant to multiply the KernelPoint by
      • mutableMultiply

        public void mutableMultiply(double c)
        Alters all the KernelPoint objects contained in this set by the same constant value
        Parameters:
        c - the constant to multiply the KernelPoints by
      • mutableAdd

        public void mutableAdd(int k,
                               double c,
                               Vec x_t,
                               java.util.List<java.lang.Double> qi)
        Alters ones of the KernelPoint objects by adding / subtracting a vector from it
        Parameters:
        k - the index of the KernelPoint to use
        c - the constant to multiply the vector being added by
        x_t - the vector to add to the kernel point
        qi - the query information for the vector, or null only if the kernel in use does not support acceleration.
      • mutableAdd

        public void mutableAdd(Vec x_t,
                               Vec cs,
                               java.util.List<java.lang.Double> qi)
        Alters some of the KernelPoints by adding / subtracting a vector from it
        Parameters:
        x_t - the vector to add to the kernel point
        cs - the array with the constant multiplies. Each non zero in cs is a constant to update one of the vectors by. The vector updated is the one corresponding to the index of the non zero value
        qi - the query information for the vector, or null only if the kernel in use does not support acceleration.
      • addNewKernelPoint

        public void addNewKernelPoint()
        Adds a new Kernel Point to the internal list this object represents. The new Kernel Point will be equivalent to creating a new KernelPoint directly.
      • getBasisSize

        public int getBasisSize()
        Returns the number of basis vectors in use. If a vector has been added to more than one Kernel Point it may get double counted (or more), so the value returned may not be reasonable in that case.
        Returns:
        the number of basis vectors in use
      • getRawBasisVecs

        public java.util.List<Vec> getRawBasisVecs()
        Returns a list of the raw vectors being used by the kernel points. Altering this vectors will alter the same vectors used by these objects and will cause inconsistent results.
        Returns:
        the list of raw basis vectors used by the Kernel points
      • size

        public int size()
        Returns the number of KernelPoints stored in this set
        Returns:
        the number of KernelPoints stored in this set
      • clone

        public KernelPoints clone()
        Overrides:
        clone in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.