JuliaGaussianProcesses / KernelFunctions.jl

Julia package for kernel functions for machine learning
https://juliagaussianprocesses.github.io/KernelFunctions.jl/stable/
MIT License
267 stars 32 forks source link

Adding `AbstractKernel` #509

Open Crown421 opened 1 year ago

Crown421 commented 1 year ago

This might be a controversial point, but I have a few times been surprised by the fact that Kernel is an abstract type.

I would like to propose/ consider adding AbstractKernel, with the subtypes SimpleKernel, MOKernel and Kernel, where Kernel would further be the supertype of the various kernels that are not mentioned. This would be in line with how kernelmatrix is defined, which is specialized for SimpleKernels and for all concrete instances of MOKernels, but falls back to kernel.(x, permutedims(y)) for Kernels, which should continue.

devmotion commented 1 year ago

I don't have a strong opinion on the name Kernel vs AbstractKernel - there is no consensus in Julia (not even in Base - AbstractArray, Real and Number are all abstract types) about whether abstract types should be named Abstract... or not. Sometimes Abstract... seems nice because then the non-Abstract name can be used for a concrete default implementation - but that's not an argument here since there is no default kernel type. Also with this proposal SimpleKernel etc. would be abstract types that are not of the form Abstract....

In any case, I think at most Kernel could be renamed to AbstractKernel but I don't see a reason to add a new abstract sub-type for kernels that are neither SimpleKernel nor MOKernel.