jsat.distributions.kernels
Class KernelPoint
- java.lang.Object
-
- jsat.distributions.kernels.KernelPoint
-
public class KernelPoint extends java.lang.ObjectThe Kernel Point represents a kernelized weight vector by a linear combination of vectors transformed through akernel fuctiion. This implementation allows the selection of multiple different budget maintenance strategies
SeeKernelRLSandProjectronfor methods and papers based on the same ideas used to create this class.
Credit goes to Davis King of the dlib library for the idea of this type of class.
Changing thebudget maintinance methodor other parameters should be done before adding any data points to the KernelPoint.
If a maximum budget is specified, it may always be increased - but may not be decreased.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classKernelPoint.BudgetStrategyThese enums control the method used to reduce the size of the support vector set in the kernel point.
-
Constructor Summary
Constructors Constructor and Description KernelPoint(KernelPoint toCopy)Copy constructorKernelPoint(KernelTrick k, double errorTolerance)Creates a new Kernel Point, which is a point in the kernel space represented by an accumulation of vectors and uses theKernelPoint.BudgetStrategy.PROJECTIONstrategy with an unbounded maximum budget
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description KernelPointclone()doubledist(KernelPoint x)Computes the Euclidean distance between this kernel point and the given kernel point in the kernel spacedoubledist(Vec x)Computes the Euclidean distance between this kernel point and the given input in the kernel spacedoubledist(Vec x, java.util.List<java.lang.Double> qi)Computes the Euclidean distance between this kernel point and the given input in the kernel spacedoubledot(KernelPoint x)Returns the dot product between this point and another in the kernel spacedoubledot(Vec x)Computes the dot product between the kernel point this object represents and the given input vector in the kernel space.doubledot(Vec x, java.util.List<java.lang.Double> qi)Computes the dot product between the kernel point this object represents and the given input vector in the kernel spaceintgetBasisSize()Returns the number of vectors serving as the basis setKernelPoint.BudgetStrategygetBudgetStrategy()Returns the budget method useddoublegetErrorTolerance()Returns the error tolerance that is used depending on theKernelPoint.BudgetStrategyin useintgetMaxBudget()Returns the current maximum budget for support vectorsjava.util.List<Vec>getRawBasisVecs()Returns the list of the raw vectors being used by the kernel points.doublegetSqrdNorm()Returns the squared values of the 2 norm of the point this object representsvoidmutableAdd(double c, Vec x_t)Alters this point to contain the given input vector as wellvoidmutableAdd(double c, Vec x_t, java.util.List<java.lang.Double> qi)Alters this point to contain the given input vector as wellvoidmutableAdd(Vec x_t)Alters this point to contain the given input vector as wellvoidmutableMultiply(double c)Alters this point to be multiplied by the given valuevoidsetBudgetStrategy(KernelPoint.BudgetStrategy budgetStrategy)Sets the method used for maintaining the budget of support vectors.voidsetErrorTolerance(double errorTolerance)Sets the error tolerance used for projection maintenance strategies such asKernelPoint.BudgetStrategy.PROJECTIONvoidsetMaxBudget(int maxBudget)Sets the maximum budget for support vectors to allow.
-
-
-
Constructor Detail
-
KernelPoint
public KernelPoint(KernelTrick k, double errorTolerance)
Creates a new Kernel Point, which is a point in the kernel space represented by an accumulation of vectors and uses theKernelPoint.BudgetStrategy.PROJECTIONstrategy with an unbounded maximum budget- Parameters:
k- the kernel to useerrorTolerance- the maximum error in [0, 1] allowed for projecting a vector instead of adding it to the basis set
-
KernelPoint
public KernelPoint(KernelPoint toCopy)
Copy constructor- Parameters:
toCopy- the object to copy
-
-
Method Detail
-
setMaxBudget
public void setMaxBudget(int maxBudget)
Sets the maximum budget for support vectors to allow. Setting toInteger.MAX_VALUEis 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
-
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 asKernelPoint.BudgetStrategy.PROJECTION- Parameters:
errorTolerance- the error tolerance in [0, 1]
-
getErrorTolerance
public double getErrorTolerance()
Returns the error tolerance that is used depending on theKernelPoint.BudgetStrategyin use- Returns:
- the error tolerance value
-
getSqrdNorm
public double getSqrdNorm()
Returns the squared values of the 2 norm of the point this object represents- Returns:
- the squared value of the 2 norm
-
dot
public double dot(Vec x)
Computes the dot product between the kernel point this object represents and the given input vector in the kernel space.- Parameters:
x- the input vector to work with- Returns:
- the dot product in the kernel space between this point and
x
-
dot
public double dot(Vec x, java.util.List<java.lang.Double> qi)
Computes the dot product between the kernel point this object represents and the given input vector in the kernel space- Parameters:
x- the input vector to work withqi- the query information for the vector, ornullonly if the kernel in use does not support acceleration.- Returns:
- the dot product in the kernel space between this point and
x
-
dot
public double dot(KernelPoint x)
Returns the dot product between this point and another in the kernel space- Parameters:
x- the point to take the dot product with- Returns:
- the dot product in the kernel space between this point and
x
-
dist
public double dist(Vec x)
Computes the Euclidean distance between this kernel point and the given input in the kernel space- Parameters:
x- the input vector to work with- Returns:
- the Euclidean distance between this point and
xin the kernel space
-
dist
public double dist(Vec x, java.util.List<java.lang.Double> qi)
Computes the Euclidean distance between this kernel point and the given input in the kernel space- Parameters:
x- the input vector to work withqi- the query information for the vector, ornullonly if the kernel in use does not support acceleration.- Returns:
- the Euclidean distance between this point and
xin the kernel space
-
dist
public double dist(KernelPoint x)
Computes the Euclidean distance between this kernel point and the given kernel point in the kernel space- Parameters:
x- the input point to work with- Returns:
- the Euclidean distance between this point and
xin the kernel space
-
mutableMultiply
public void mutableMultiply(double c)
Alters this point to be multiplied by the given value- Parameters:
c- the value to multiply by
-
mutableAdd
public void mutableAdd(Vec x_t)
Alters this point to contain the given input vector as well- Parameters:
x_t- the vector to add
-
mutableAdd
public void mutableAdd(double c, Vec x_t)Alters this point to contain the given input vector as well- Parameters:
c- the multiplicative constant to apply with the vectorx_t- the vector to add
-
mutableAdd
public void mutableAdd(double c, Vec x_t, java.util.List<java.lang.Double> qi)Alters this point to contain the given input vector as well- Parameters:
c- the multiplicative constant to apply with the vectorx_t- the vector to addqi- the query information for the vector, ornullonly if the kernel in use does not support acceleration.
-
getBasisSize
public int getBasisSize()
Returns the number of vectors serving as the basis set- Returns:
- the number of vectors serving as the basis set
-
getRawBasisVecs
public java.util.List<Vec> getRawBasisVecs()
Returns the list of the raw vectors being used by the kernel points. Altering this vectors will alter the same vectors used by the KernelPoint and will cause inconsistent results.
The returned list may not be modified- Returns:
- a the list of all the vectors in use as a basis set by this KernelPoint
-
clone
public KernelPoint clone()
- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG