Kernel Function
A kernel function is a specific type of
mathematical funciton that is particularly useful in certain machine learning and pattern recognition
contexts. The density_sketch
performs approximate
kernel density estimation which, unsurprisingly,
relies on the use of such a kernel function.
The library provides an abstract base class KernelFunction
and an example implementation of a
Gaussian (also known as a Radial Basis Function) kernel. Custom classes must override the base class
and provide a floating point value as a score indicating the similarity of two input vectors.
- class KernelFunction(*args, **kwargs)
A generic base class from which user-defined kernels must inherit.
- __call__(self, a: object, b: object) float
A method to evaluate a kernel with given inputs a and b.
- Parameters:
a (numpy array) – An input vector
b (numpy array) – An input vector
- Returns:
A vector similarity score
- Return type:
float
- class GaussianKernel(bandwidth: float = 1.0)
Bases:
KernelFunction
Implements a basic Gaussian kernel
- Parameters:
bandwidth (float) – The kernel bandwidth, default 1.0