Questions tagged [mahalanobis]

A dissimilarity metric to compute distance between a point and a distribution.

Learn more about the Mahalanobis distance on Wikipedia


Tag usage

Questions on should be about implementation and programming problems, not about the statistical or theoretical properties of such metric.
Consider whether the question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

96 questions
0
votes
1 answer

How to write code the Chebyshev and Mahalanobis distance using bsxfun function in matlab?

I found the sample code to calculate distance of two matrix using euclidean distance from here: Finding K-nearest neighbors and its implementation The data matrix are as below: load fisheriris X = meas(:,3:4); newpoints = [5 1.45; 7 2; 4 2.5; 2…
amjay
  • 11
  • 6
0
votes
2 answers

Squared Mahalanobis distance function in Python returning array - why?

The code is: import numpy as np def Mahalanobis(x, covariance_matrix, mean): x = np.array(x) mean = np.array(mean) covariance_matrix = np.array(covariance_matrix) return…
Sibs
  • 81
  • 1
  • 11
0
votes
1 answer

matlab Pdist2 with mahalanobis metric

How can i use pdist2 with 'mahalanobis' metric? I write this code : u=[1 2 3; 4 5 6; 7 8 9]; n=[1 2 5;2 5 7;5 7 9]; covu=nancov(u); Z=pdist2(u,u,'mahalanobis',covu); But i get this error: ??? Error using ==> pdist2 at 298 The covariance matrix for…
0
votes
1 answer

Problems using the Mahalanobis distance in the KNN algorithm

I'm a student and I'm trying to do this homework, where I need to do the KNN algorith with the Mahalanobis distance as parameter, but for some reason that I can't figure out, my code is not working. I'm not a R master, actually I know only the…
Bruno Camarda
  • 75
  • 1
  • 1
  • 8
0
votes
0 answers

Calculate distance in a point cloud as cube distances

I'm working with python on a 3d point cloud files that are in format XYZ, I need to calculate the distance from each one of them to the center, and then label (and colour for better visualization) them according to it. So far I got this cloud…
0
votes
0 answers

How to implement Mahalanobis Distance in Matlab for Eigenfaces

I'm trying to implement the Eigenfaces algorithm and was able to check if a face matches by checking the euclidean distance as shown below. I would like to improve the code using Mahalanobis Distance instead. similarity_score = arrayfun(@(n) 1 / (1…
0
votes
1 answer

Java - sometimes return NaN when calculating Mahalanobis distance

I use org.apache.mahout.common.distance.MahalanobisDistanceMeasure to calculate the distance between rows in a matrix and the mean vector, but it sometimes returns NaN. I tried to debug and it seems that a NullPointerException is thrown in the…
simon s
  • 135
  • 1
  • 4
  • 15
0
votes
1 answer

How to successsfully run an ML algorithm with a medium sized data set on a mediocre laptop?

I have a Lenovo IdeaPad laptop with 8 GB RAM and Intel Core I5 processor. I have 60k data points each 100 dimentional. I want to do KNN and for it I am running LMNN algorithm to find a Mahalanobis Metric. Problem is after 2 hours of running a blank…
Fenil
  • 21
  • 3
0
votes
1 answer

How do I make a Mahalanobis distance matrix in MATLAB?

I have a data set with 5 repeats for each sample and 25 variables. I am trying to make a Mahalanobis distance matrix between all of the samples using these parameters. I used the "mahal" function, but this gives a vector of all of the distances for…
Tali b
  • 1
0
votes
0 answers

Identifying Outliers in a Set of 1-D Binary Vectors in Python

I am investigating the optimal way to identify outlier vectors when you have m 1-D binary vectors with n features, for example: a =[[1, 0, 1, 1, 1, 0, 1], [0, 0, 0, 1, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]] In my case n and m are in the 100's. I…
chemnteach
  • 375
  • 8
  • 23
0
votes
2 answers

clustering using a proximity matrix in r

I have a proximity matrix (dissimilarity) of an mahalanobis distance. the matrix (sample): > dput(MD[1:5,1:5]) structure(c(0, 10.277, 8.552, 8.592, 9.059, 10.277, 0, 10.917, 9.489, 8.176, 8.552, 10.917, 0, 8.491, 8.104, 8.592, 9.489, 8.491, 0,…
user7267969
0
votes
1 answer

Mahalanobis distance in VBA

I am trying to calculate Mahalanobis distances in VBA. I have created my UDF to calculate Covarince matrix but i got a #value error when executing my function. could you give me some help Thanks in advance! Function DMahalanobis(x As Range, y As…
Moreno
  • 608
  • 1
  • 9
  • 24
0
votes
0 answers

Sklearn KNN + mahalanobis on python

I try to use the function NearestNeighbors on Sklearn. I write an example to understand what's happening on these function. from sklearn.neighbors import NearestNeighbors samples = [[0.2, 0], [0.5, 0.1], [0.4,0.4]] neigh =…
Jack
  • 1
  • 3
0
votes
0 answers

Online Metric Learning for Face Recognition

I'm using OpenFace to compute representations (in 128D) for faces found in images taken under unconstrained conditions that show significant variations in lighting, time, etc. According to their website and demos, a standard Euclidean distance with…
0
votes
0 answers

How can I improve numpy's broadcast

I'm trying implementing k-NN with Mahalanobis's distance in python with numpy. However, the code below works very slowly when I use broadcasting. Please teach me how can I improve numpy speed or implement this better. from __future__ import…