Can someone highlight my Matlab program? I have data from two sensors, and I carry out the classification kNNfor each of them separately. In both cases, the training set looks like a set of vectors of 42 lines, for example:
[44 12 53 29 35 30 49;
54 36 58 30 38 24 37;..]
Then I get a sample, for example. [40 30 50 25 40 25 30], and I want to classify the sample to its nearest neighbor. As a proximity criterion, I use Euclidean metrics, sqrt (sum (Y 2 )) , where Yis the difference between each element, and this gives me an array of distance between the sample and each class of training sets.
So, two questions:
- Is it possible to convert the distance to a probability distribution, for example: Class1: 60%, class 2: 30%, class 3: 5%, class 5: 1%, etc.
Added: So far I am using the formula:, probability = distance/sum of distancesbut I can’t build the correct one cdfor a histogram. This gives me some kind of distribution, but I see the problem there, because if the distance is great, for example 700, then the closest class will get the most probability, but that would be wrong, because the distance is too great to be compared to any of classes.
- If I could get two probability density functions, I guess I would do some of them. Is it possible?
Any help or comment is greatly appreciated.