kernels
¶Kernels!
SwitchError |
|
lazy_kernel (xdata[, ydata, kernel_type, dtype]) |
Generate kernels from cache |
gaussian_kernel (xdata[, ydata, sigma]) |
Compute the gaussian kernel along the first dimension This uses the vector_norm_sq() to compute the norms across the vectors in the matrices and then re-scales it |
homogeneous_polykern (data[, ydata, powa]) |
Compute the homogeneous polynomial kernel. |
inhomogeneous_polykern (data[, ydata, powa]) |
Compute the homogeneous polynomial kernel. |
linear_kernel (xdata[, ydata]) |
Compute a linear kernel |
multiquad_kernel (xdata[, ydata, c]) |
Compute the multi-quadratic kernel. |
vector_norm_sq (xdata[, ydata]) |
Compute the squared vector norm. |
volterra_temporal (X[, delays, degree]) |
Volterra series. |
lazy_kernel
¶tikreg.kernels.
lazy_kernel
(xdata, ydata=None, kernel_type=None, dtype=<type 'numpy.float64'>)¶Bases: object
Generate kernels from cache
Some kernels operate on the inner-product space, others operate on vector norms. This class caches these matrices and lets the user construct the kernel with a given parameter from the cache. This is fast because the inner-products don’t need to be recomputed every time a new parameter is passed. This is useful when cross-validating kernel parameters (e.g. for a gaussian kernel) or when switching between different kernels types (e.g. from gaussian to multi-quadratic).
__init__
(self, xdata, ydata=None, kernel_type=None, dtype=<type 'numpy.float64'>)¶Parameters: |
|
---|
update
(self, kernel_parameter, kernel_type=None, verbose=False)¶Update the kernel with the parameter given.
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
gaussian_kernel
(xdata, ydata=None, sigma=1.0)¶Compute the gaussian kernel along the first dimension
This uses the vector_norm_sq()
to compute
the norms across the vectors in the matrices
and then re-scales it
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
homogeneous_polykern
(data, ydata=None, powa=2)¶Compute the homogeneous polynomial kernel.
The polynomial expansion does not include interactions.
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
inhomogeneous_polykern
(data, ydata=None, powa=2)¶Compute the homogeneous polynomial kernel.
The polynomial expansion includes interaction terms.
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
linear_kernel
(xdata, ydata=None)¶Compute a linear kernel
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
multiquad_kernel
(xdata, ydata=None, c=1.0)¶Compute the multi-quadratic kernel.
Parameters: |
|
---|---|
Returns: |
|
tikreg.kernels.
vector_norm_sq
(xdata, ydata=None)¶Compute the squared vector norm.
This assumes the vectors are in the first dimension.
Parameters: |
|
---|---|
Returns: |
|
Examples
>>> xdata = np.arange(3*10).reshape(3,10)
>>> print(vector_norm_sq(xdata))
[[ 0 1000 4000]
[1000 0 1000]
[4000 1000 0]]