Closed alior101 closed 9 months ago
Ok, I figured this out alone.. Documenting for anyone elese exepriencing this Turns out that the distance function types must match
function (::MyMetric)(a::Float64, b::Float64)
sum(abs.(a - b))
end
fixed it
As it says (I understand that we are not very good spelling out the requirements upfront): you need to define another method that deals with the "scalar" case:
(::MyMetric)(a::Float64, b::Float64) = abs(a - b)
This is required for the determination of the target eltype.
Note that your example is the squared Euclidean distance. Which means that integer vectors yield an integer distance. If you want the Euclidean distance (just to demonstrate the reasoning), you should take the square root in your vector-method, and perhaps define
(::MyMetric)(a::Float64, b::Float64) = float(a - b)
This issue should be closed. The above answers are good! Thank you.
I did (::MyMetric)(::Real, ::Real) = NaN
.
Trying a simple custom metric (which is just euclidian distan)
I'm getting
Any idea what am I missing ?