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

Remove input check for vector of vectors #513

Open grero opened 1 year ago

grero commented 1 year ago

Summary

This attempts to address #512, which prevents kernels operating on vectors of unequal length from working properly.

Proposed changes

What alternatives have you considered?

The most obvious alternative would be to implement my own type, wrapping AbstractVector{<:AbstractVector{<:Real}}, but since this change would potentially benefit others with similar needs, a fix in KernelFunctions itself seemed more appropriate. Breaking changes

The main change is that inputs checks that are currently failing would pass. This is potentially breaking, as it is possible that downstream code could rely on these checks.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage has no change and project coverage change: -14.31 :warning:

Comparison is base (ef6d459) 94.16% compared to head (6b153d9) 79.85%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #513 +/- ## =========================================== - Coverage 94.16% 79.85% -14.31% =========================================== Files 52 52 Lines 1387 1385 -2 =========================================== - Hits 1306 1106 -200 - Misses 81 279 +198 ``` | [Impacted Files](https://app.codecov.io/gh/JuliaGaussianProcesses/KernelFunctions.jl/pull/513?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaGaussianProcesses) | Coverage Δ | | |---|---|---| | [src/utils.jl](https://app.codecov.io/gh/JuliaGaussianProcesses/KernelFunctions.jl/pull/513?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaGaussianProcesses#diff-c3JjL3V0aWxzLmps) | `69.87% <ø> (-21.59%)` | :arrow_down: | ... and [18 files with indirect coverage changes](https://app.codecov.io/gh/JuliaGaussianProcesses/KernelFunctions.jl/pull/513/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaGaussianProcesses)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

willtebbutt commented 1 year ago

Thanks for opening this PR.

I understand why you've taken this approach, but I don't believe it's the correct approach, as whether or not the input-dimension comparison should be performed is a function of the kernel, not the input type. For example, it (should be) perfectly fine to feed a Vector{Vector{Float64}} into an SEKernel, and in that case we would generally like to check that the input dimensions match.

To my mind, a better implementation would be to switch the check on / off depending upon which kernel is employed.

@theogf @devmotion @st-- do any of you have thoughts on this problem? I'm starting to wonder whether having this check is more hassle than it's worth, because the fix looks like it's going to be a bit tricky to implement.

devmotion commented 1 year ago

To my mind, a better implementation would be to switch the check on / off depending upon which kernel is employed.

Yes, I agree, that seems to be the best and most general approach. Maybe also dim is too specific and instead we should add a function such as are_valid_inputs(kernel, x, y)::Bool as the basis of valid_inputs?