Experimenting with different distance metrics, coded as ES6 modules. Start with simplest example, Euclidean Distance. Note not all distances will be true metrics, for example, cosine distance does not satisfy triangular inequality, as demonstrated here:
A=[1,0];
B=[0.6,0.8];
C=[-0.8,0.6];Geeting the metrics module
mod = (await import('https://epiverse.github.io/metrics/basic.mjs'))
show an example of triangular innequality not being satisfied by cosine distance:
dAB = mod.cosine(A,B) = 0.4
dBC = mod.cosine(B,C) = 1
dAC = mod.cosine(A,C) = 1.8
dAC<=(dAB+dBC) = falseFor more discussion of the metrics modules see the metrics wiki