API Library
Functions
KernelFunctions.kernelmatrix
— Functionkernelmatrix(κ::Kernel, X; obsdim::Int = 2)
kernelmatrix(κ::Kernel, X, Y; obsdim::Int = 2)
Calculate the kernel matrix of X
(and Y
) with respect to kernel κ
. obsdim = 1
means the matrix X
(and Y
) has size #samples x #dimension obsdim = 2
means the matrix X
(and Y
) has size #dimension x #samples
KernelFunctions.kernelmatrix!
— Functionkernelmatrix!(K::AbstractMatrix, κ::Kernel, X; obsdim::Integer = 2)
kernelmatrix!(K::AbstractMatrix, κ::Kernel, X, Y; obsdim::Integer = 2)
In-place version of kernelmatrix
where pre-allocated matrix K
will be overwritten with the kernel matrix.
KernelFunctions.kernelmatrix_diag
— Functionkernelmatrix_diag(κ::Kernel, X; obsdim::Int = 2)
Calculate the diagonal matrix of X
with respect to kernel κ
obsdim = 1
means the matrix X
has size #samples x #dimension obsdim = 2
means the matrix X
has size #dimension x #samples
kernelmatrix_diag(κ::Kernel, X, Y; obsdim::Int = 2)
Calculate the diagonal of kernelmatrix(κ, X, Y; obsdim)
efficiently. Requires that X
and Y
are the same length.
KernelFunctions.kernelmatrix_diag!
— Functionkernelmatrix_diag!(K::AbstractVector, κ::Kernel, X; obsdim::Int = 2)
kernelmatrix_diag!(K::AbstractVector, κ::Kernel, X, Y; obsdim::Int = 2)
In place version of kernelmatrix_diag
KernelFunctions.kernelpdmat
— Functionkernelpdmat(k::Kernel, X::AbstractMatrix; obsdim::Int=2)
kernelpdmat(k::Kernel, X::AbstractVector)
Compute a positive-definite matrix in the form of a PDMat
matrix see PDMats.jl with the cholesky decomposition precomputed. The algorithm recursively tries to add recursively a diagonal nugget until positive definiteness is achieved or until the noise is too big.
KernelFunctions.nystrom
— Functionnystrom(k::Kernel, X::Matrix, S::Vector; obsdim::Int=defaultobs)
Computes a factorization of Nystrom approximation of the square kernel matrix of data matrix X
with respect to kernel k
. Returns a NystromFact
struct which stores a Nystrom factorization satisfying:
\[\mathbf{K} \approx \mathbf{C}^{\intercal}\mathbf{W}\mathbf{C}\]
nystrom(k::Kernel, X::Matrix, r::Real; obsdim::Int=defaultobs)
Computes a factorization of Nystrom approximation of the square kernel matrix of data matrix X
with respect to kernel k
using a sample ratio of r
. Returns a NystromFact
struct which stores a Nystrom factorization satisfying:
\[\mathbf{K} \approx \mathbf{C}^{\intercal}\mathbf{W}\mathbf{C}\]
Utilities
KernelFunctions.ColVecs
— TypeColVecs(X::AbstractMatrix)
A lightweight wrapper for an AbstractMatrix
to make it behave like a vector of vectors. Each vector represents a column of the matrix
KernelFunctions.RowVecs
— TypeRowVecs(X::AbstractMatrix)
A lightweight wrapper for an AbstractMatrix
to make it behave like a vector of vectors. Each vector represents a row of the matrix
KernelFunctions.MOInput
— TypeMOInput(x::AbstractVector, out_dim::Integer)
A data type to accomodate modelling multi-dimensional output data.
KernelFunctions.NystromFact
— TypeNystromFact
Type for storing a Nystrom factorization. The factorization contains two fields: W
and C
, two matrices satisfying:
\[\mathbf{K} \approx \mathbf{C}^{\intercal}\mathbf{W}\mathbf{C}\]