Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert distance into probability?

Сan anyone shine a light to my matlab program? I have data from two sensors and i'm doing a kNN classification for each of them separately. In both cases training set looks like a set of vectors of 42 rows total, like this:

[44 12 53 29 35 30 49;

 54 36 58 30 38 24 37;..]

Then I get a sample, e.g. [40 30 50 25 40 25 30] and I want to classify the sample to its closest neighbor. As a criteria of proximity I use Euclidean metrics, sqrt(sum(Y2)), where Y is a difference between each element and it gives me an array of distances between Sample and each Class of Training Set.

So, two questions:

  • Is it possible to convert distance into distribution of probabilities, something like: Class1: 60%, Class 2: 30%, Class 3: 5%, Class 5: 1%, etc.

added: Up to this moment I'm using formula: probability = distance/sum of distances, but I cannot plot a correct cdf or histogram. This gives me a distribution in some way, but I see a problem there, because if distance is large, for example 700, then the closest class will get a biggest probability, but it'd be wrong because the distance is too big to be compared with any of classes.

  • If I would be able to get two probability density functions, I guess then I would do some product of them. Is it possible?

Any help or remark is highly appreciated.

like image 773
niko_dry Avatar asked May 04 '14 18:05

niko_dry


1 Answers

You could try to inverse your distances to get a likelihood measure. I.e. the bigger the distance x, the smaller the inverse of it. Then, you can normalize as in probability = (1/distance) / (sum (1/distance) )

like image 146
Adam Kosiorek Avatar answered Oct 14 '22 22:10

Adam Kosiorek