public class KernelPoint extends Object
kernel fuctiion
. This implementation allows the selection
of multiple different budget maintenance strategies KernelRLS
and Projectron
for methods and papers based on
the same ideas used to create this class. budget maintinance method
or other parameters should be done before
adding any data points to the KernelPoint. Modifier and Type | Class and Description |
---|---|
static class |
KernelPoint.BudgetStrategy
These enums control the method used to reduce the size of the support
vector set in the kernel point.
|
Modifier and Type | Field and Description |
---|---|
protected DoubleList |
alpha |
protected KernelPoint.BudgetStrategy |
budgetStrategy |
protected Matrix |
InvK |
protected Matrix |
InvKExpanded |
protected KernelTrick |
k |
protected Matrix |
K |
protected List<Double> |
kernelAccel |
protected Matrix |
KExpanded |
protected int |
maxBudget |
protected List<Vec> |
vecs |
Constructor and Description |
---|
KernelPoint(KernelPoint toCopy)
Copy constructor
|
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 the
KernelPoint.BudgetStrategy.PROJECTION strategy with an unbounded maximum
budget |
Modifier and Type | Method and Description |
---|---|
KernelPoint |
clone() |
double |
dist(KernelPoint x)
Computes the Euclidean distance between this kernel point and the given
kernel point in the kernel space
|
double |
dist(Vec x)
Computes the Euclidean distance between this kernel point and the given
input in the kernel space
|
double |
dist(Vec x,
List<Double> qi)
Computes the Euclidean distance between this kernel point and the given
input in the kernel space
|
double |
dot(KernelPoint x)
Returns the dot product between this point and another in the kernel
space
|
double |
dot(Vec x)
Computes the dot product between the kernel point this object represents
and the given input vector in the kernel space.
|
double |
dot(Vec x,
List<Double> qi)
Computes the dot product between the kernel point this object represents
and the given input vector in the kernel space
|
protected void |
finalMergeStep(int m,
int n,
Vec n_z,
List<Double> nz_qi,
double n_alpha_z,
boolean alterVecs)
Performs the last merging step removing the old vecs and adding the new
merged one
|
int |
getBasisSize()
Returns the number of vectors serving as the basis set
|
KernelPoint.BudgetStrategy |
getBudgetStrategy()
Returns the budget method used
|
double |
getErrorTolerance()
Returns the error tolerance that is used depending on the
KernelPoint.BudgetStrategy in use |
protected static double |
getH(double k_mn,
double a_m,
double a_n)
Gets the minimum of H in [0, 1] the for RBF merging
amkmn(1-h)^2 + ankmnh^2 . |
int |
getMaxBudget()
Returns the current maximum budget for support vectors
|
List<Vec> |
getRawBasisVecs()
Returns the list of the raw vectors being used by the kernel points.
|
double |
getSqrdNorm()
Returns the squared values of the 2 norm of the point this object
represents
|
void |
mutableAdd(double c,
Vec x_t)
Alters this point to contain the given input vector as well
|
void |
mutableAdd(double c,
Vec x_t,
List<Double> qi)
Alters this point to contain the given input vector as well
|
void |
mutableAdd(Vec x_t)
Alters this point to contain the given input vector as well
|
void |
mutableMultiply(double c)
Alters this point to be multiplied by the given value
|
protected void |
removeIndex(int toRemove)
Removes the vec, alpha, and kernel cache associate with the given index
|
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.
|
protected KernelTrick k
protected Matrix K
protected Matrix InvK
protected Matrix KExpanded
protected Matrix InvKExpanded
protected DoubleList alpha
protected KernelPoint.BudgetStrategy budgetStrategy
protected int maxBudget
public KernelPoint(KernelTrick k, double errorTolerance)
KernelPoint.BudgetStrategy.PROJECTION
strategy with an unbounded maximum
budgetk
- the kernel to useerrorTolerance
- the maximum error in [0, 1] allowed for projecting
a vector instead of adding it to the basis setpublic KernelPoint(KernelPoint toCopy)
toCopy
- the object to copypublic void setMaxBudget(int maxBudget)
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.maxBudget
- the maximum number of allowed support vectorspublic int getMaxBudget()
public void setBudgetStrategy(KernelPoint.BudgetStrategy budgetStrategy)
budgetStrategy
- the budget maintenance strategypublic KernelPoint.BudgetStrategy getBudgetStrategy()
public void setErrorTolerance(double errorTolerance)
KernelPoint.BudgetStrategy.PROJECTION
errorTolerance
- the error tolerance in [0, 1]public double getErrorTolerance()
KernelPoint.BudgetStrategy
in usepublic double getSqrdNorm()
public double dot(Vec x)
x
- the input vector to work withx
public double dot(Vec x, List<Double> qi)
x
- the input vector to work withqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.x
public double dot(KernelPoint x)
x
- the point to take the dot product withx
public double dist(Vec x)
x
- the input vector to work withx
in the
kernel spacepublic double dist(Vec x, List<Double> qi)
x
- the input vector to work withqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.x
in the
kernel spacepublic double dist(KernelPoint x)
x
- the input point to work withx
in the
kernel spacepublic void mutableMultiply(double c)
c
- the value to multiply bypublic void mutableAdd(Vec x_t)
x_t
- the vector to addpublic void mutableAdd(double c, Vec x_t)
c
- the multiplicative constant to apply with the vectorx_t
- the vector to addpublic void mutableAdd(double c, Vec x_t, List<Double> qi)
c
- the multiplicative constant to apply with the vectorx_t
- the vector to addqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.protected void finalMergeStep(int m, int n, Vec n_z, List<Double> nz_qi, double n_alpha_z, boolean alterVecs)
m
- the first of the original index to removen
- the second of the original index to removen_z
- the merged vec to replace them withnz_qi
- the query info for the new vecn_alpha_z
- the alpha value for the new merged vecprotected static double getH(double k_mn, double a_m, double a_n)
k_mn
- the shared kernel value on both halves of the equationa_m
- the first coefficienta_n
- the second coefficientprotected void removeIndex(int toRemove)
toRemove
- the index to removepublic int getBasisSize()
public List<Vec> getRawBasisVecs()
public KernelPoint clone()
Copyright © 2017. All rights reserved.