public class KernelPoints extends Object
KernelPoint
objects. This is done to
avoid excessive memory duplication that can occur when multiple KernelPoints
are in use at the same time.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
|
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,
List<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,
List<Double> qi)
Computes the dot product between the
k 'th KernelPoint and the
given vector in the kernel space. |
double[] |
dot(Vec x,
List<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
|
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,
List<Double> qi)
Alters ones of the KernelPoint objects by adding / subtracting a vector
from it
|
void |
mutableAdd(Vec x_t,
Vec cs,
List<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
|
public KernelPoints(KernelTrick k, int points, double errorTolerance)
k
- the kernel trick to use in which to represent a vector in the
kernel spacepoints
- the initial number of kernel points to store in this seterrorTolerance
- the maximum error allowed for projecting a vector
instead of adding it to the basis setpublic KernelPoints(KernelTrick k, int points, double errorTolerance, boolean mergeGrams)
k
- the kernel trick to use in which to represent a vector in the
kernel spacepoints
- the initial number of kernel points to store in this seterrorTolerance
- the maximum error allowed for projecting a vector
instead of adding it to the basis setmergeGrams
- whether or not to merge the gram matrices of each
KernelPoint.public KernelPoints(KernelPoints toCopy)
toCopy
- the object to copypublic void setBudgetStrategy(KernelPoint.BudgetStrategy budgetStrategy)
budgetStrategy
- the budget maintenance strategypublic KernelPoint.BudgetStrategy getBudgetStrategy()
public KernelTrick getKernel()
public void setErrorTolerance(double errorTolerance)
KernelPoint.BudgetStrategy.PROJECTION
errorTolerance
- the error tolerance in [0, 1]public double getErrorTolerance()
KernelPoint.BudgetStrategy
in usepublic 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 double getSqrdNorm(int k)
k
'th KernelPointk
- the KernelPoint to get the norm ofk
'th KernelPointpublic double dot(int k, Vec x, List<Double> qi)
k
'th KernelPoint and the
given vector in the kernel space.k
- the index of the KernelPoint in this set to contribute to the
dot productx
- the vector to contribute to the dot productqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.k
'th KernelPoint and the
given vectorpublic double[] dot(Vec x, List<Double> qi)
dot(int, jsat.linear.Vec, java.util.List)
x
- the vector to contribute to the dot productqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.public double dot(int k, KernelPoint x)
k
'th KernelPoint and the
given KernelPointk
- the index of the KernelPoint in this set to contribute to the
dot productx
- the other KernelPoint to contribute to the dot productk
'th KernelPoint and the
given KernelPointpublic double dot(int k, KernelPoints X, int j)
k
'th KernelPoint and the
j
'th KernelPoint in the given set of points.k
- the index of the KernelPoint in this set to contribute to the
dot productX
- the other set of KernelPointsj
- the index of the KernelPoint in the given set to contribute to
the dot productk
'th KernelPoint and the
j
'th KernelPoint in the given setpublic double dist(int k, Vec x, List<Double> qi)
k
'th KernelPoint and the given vectork
- the index of the KernelPoint in this set to contribute to the
dot productx
- the point to get the Euclidean distance toqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.k
'th KernelPoint and
x
in the kernel spacepublic double dist(int k, KernelPoint x)
k
'th KernelPoint and the given KernelPointk
- the index of the KernelPoint in this set to contribute to the
dot productx
- the kernel point to get the Euclidean distance tok
'th KernelPoint and
x
in the kernel spacepublic double dist(int k, KernelPoints X, int j)
k
'th KernelPoint and the j
'th KernelPoint in the given
setk
- the index of the KernelPoint in this set to contribute to the
dot productX
- the other set of kernel points to obtain the target KernelPointj
- the index of the KernelPoint in the given set to contribute to
the dot productk
'th KernelPoint and
the j
'th KernelPoint in the other setpublic void mutableMultiply(int k, double c)
k
'th KernelPoint by multiplying it with a constant
valuek
- the index of the KernelPoint to modifyc
- the constant to multiply the KernelPoint bypublic void mutableMultiply(double c)
c
- the constant to multiply the KernelPoints bypublic void mutableAdd(int k, double c, Vec x_t, List<Double> qi)
k
- the index of the KernelPoint to usec
- the constant to multiply the vector being added byx_t
- the vector to add to the kernel pointqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.public void mutableAdd(Vec x_t, Vec cs, List<Double> qi)
x_t
- the vector to add to the kernel pointcs
- 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 valueqi
- the query information for the vector, or null
only if
the kernel in use does not support acceleration.public void addNewKernelPoint()
public int getBasisSize()
public List<Vec> getRawBasisVecs()
public int size()
public KernelPoints clone()
Copyright © 2017. All rights reserved.