How to convert Euclidean distance to range 0 and 1 like Cosine Similarity?
bigdata, data-mining, machine-learning, text-mining
Solution
It seems that you want the fraction's denominator to grow more slowly (the denominator is the bottom part, which you have as (d+1) so far). There are various ways to handle this. For instance, try a lower power for d, such as
1 / (1 + d**(0.25))
... or an exponential decay in the denominator, such as
1 / (1.1 ** d)
... or using a trig function to temper your mapping, such as
1 - tanh(d)
Would something in one of these families work for you?
Problem
Want to map Euclidean distance to the range [0, 1], somewhat like the cosine similarity of vectors. For instance ``` input output 0 1.0 1 0.9 approximate 2 0.8 to 0.9 somewhere inf 0.0 ``` I tried the formula `1/(1+d)`, but that falls away from 1.0 too quickly.