Mahalanobis Distance Formula in Python

Hi, I am trying to implement the Mahalanobis distance formula in python.
Parameters:

  • points, a list of arrays that contain Iris data points
  • centroids, a list of calculated centroids

The Mahalanobis formula needs to use a positive diagonal matrix with the rank equal to n the dimension of data.

image

Hey @bdossantos109,

What exactly is your question?

To compute the Mahalanobis distance formula in python, you can follow this tutorial https://www.machinelearningplus.com/statistics/mahalanobis-distance/.

Hi,

Thanks for the link, but I am looking to use a positive diagonal matrix where it provides better performance than using an inverse covariance matrix.