2

I need to find Mahalanobis Distance between my training data and testing data for K.NN algorithm.

I found some descriptions on the internet, but I could not understand them as there was no practical example.

Training data:

flower = {s.length, s.width,    p.lenght,   p.width,    class}

x1 = {5.1,  3.5,    1.4,    0.2,    setosa}

x2 = {6.4,  3.2,    4.5,    1.5,    versicolour}

x3 = {7.1,  3,      5.9,    2.1,    virginica}

Testing data:

y1 = {4.9,  3,      1.4,    0.2, (Which class?)}

These are my data and I need to find that y1 belongs to which class according to my training data? (this data belongs to setosa class, but I need to prove it's using Mahalanobis Distance)

Any help will be appreciated.

Shekofa
  • 21
  • 2
  • If you have access to the Statistics and Machine learning toolbox, there are ways described in the [documentation to compute Mahalanobis distance](https://de.mathworks.com/help/stats/mahal.html) using `mahal`. – mikkola Oct 14 '17 at 11:12
  • Was searching for similar thing found this pretty useful: https://franciscomorales.org/2017/03/09/how-to-python-calculate-mahalanobis-distance/ – MichaelMMeskhi Nov 19 '17 at 06:55

0 Answers0