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
0 answers

Sklearn NearestNeighbors with mahalanobis distance returns error for slice of array

The following code returns an error: import numpy as np from sklearn.datasets import make_classification from sklearn.neighbors import NearestNeighbors X, y = make_classification() nn = NearestNeighbors(algorithm='brute', …
Yandle
  • 287
  • 1
  • 10
0
votes
0 answers

How to find outliers in multivariate data with weak covariance

I have used PCA and Mahalanobis distance to find outliers. But in both cases, only the highest or lowest values are detected as outliers. I am looking for a way that any data point that does not follow a certain correlation between output and 3…
0
votes
1 answer

Calclulate the Mahalanobis distance with org.apache.commons.math3 only

Is there a way to calculate Mahalanobis distance ommiting org.apache.mahout usage (by using only org.apache.commons.math3)?
AndreyP
  • 2,510
  • 1
  • 29
  • 17
0
votes
1 answer

How do I create a unique MatchID for pairs/groups in my MatchIt code?

I've implemented the MatchIt package in R as part of my master thesis research. The code currently matches some sustainable investment firms with non-sustainable investment firms on a ratio of 1:2. I need to amend my code so that the matches have a…
R Wd
  • 59
  • 5
0
votes
1 answer

MatchIt - how to make matching date specific?

I'm trying to use MatchIt to create two sets of matched investment companies (treatment vs control). I need to match the treatment companies to the control companies using only data from the 1-3 years proceeding the treatment. For example if a…
0
votes
1 answer

MatchIt combined with lapply(): Error in eval(object$call$data, envir = env) : object 'x' not found

So my situation is the following: I have a large dataframe which contains the data I should use in matching analyses. I should, however, match inside subgroups that are defined by certain areas. Because I didn't want to do that "manually" for each…
Pinus
  • 17
  • 4
0
votes
1 answer

Python Mahalanobis distance multidimensional z-score

I want a performance score, like a z-score, for two-dimensional data around a known fixed point. I think I want the Mahalanobis distance now, rather than z-scores in each direction. But I don't have two vectors, I have a 2 x N array of positions of…
0
votes
1 answer

Mahalanobis distance with multiple observations, variables and groups

For the iris data set, I am trying to find the Mahalanobis distances between each pair of species. I have tried the following but have had no luck. I tried the following: group <- matrix(iris$Species) group <- t(group[,-5]) variables <-…
daisybeats
  • 217
  • 1
  • 6
0
votes
1 answer

Subclassification with Mahalanobis distance nearest neighbor matching in R

I am using the MatchIt package to implement nearest neighbor matching with the Mahalonobis distance. After the matching stage, how do I get it to report which control observation was matched with each treatment observation? The following code does…
dzeltzer
  • 990
  • 8
  • 28
0
votes
1 answer

Calculate distance between 1D array and nD array using python

I'm a beginner in python i wish you can help me to fix my problem. I have tow file library.csv (9 columns) and cases.csv (8 columns) i read them with np.loadtxt. I select columns from library to put them into array base[], except the last column…
Mastour Ikhlass
  • 99
  • 1
  • 1
  • 7
0
votes
1 answer

How to calculate Mahalanobis Distance between randomly generated values?

I'm currently learning about Mahalanobis Distance and I find it quite difficult. To get the idea better I generated 2 sets of random values (x and y) and a random point, where for all 3 mean=0 and standard deviation=1. How can I calculate the…
0
votes
0 answers

How to do a matching with the Mahalanobis distance in with the Matching package

I want to do a matching with the Matching-package. Of course, I have the treatment variable which is the first matching criterion. Then I have the second variable (C) which should be considered for the matching using the Mahalanobis distance. The…
user11652343
0
votes
1 answer

Is there any way to combine multiple distance metrics in a similarity function?

I need to find a way to code a similarity function between two vector(data instances), let's name them and . These data instances have categorical features as well as quantities. Thus, I'd like to find a way to combine, let's say Hamming Distance…
0
votes
0 answers

How Can I implement covariance of training samples by Python?

I want to implement the covariance of training samples, which can be used when calculating the Mahalanobis distance. How can I implement this equation in Python? I referenced that image in 'A Simple Unified Framework for…
모하니
  • 11
  • 3
0
votes
0 answers

Mahalanobis distance returns NaN in Pytorch

I'm testing new metrics to measure distance between weight matrices in Pytorch, right now I'm trying to use Mahalanobis. For that I reshape every matrix into a vector and concat then into one matrix and then use this matrix to calculate the…
Matheus Ianzer
  • 425
  • 8
  • 22