Calculating Mahalanobis parameters from x data
$begingroup$
Roughly speaking, the Mahalanobis distance $d(x) = sqrt{(x - mu)^T * Sigma^{-1} * (x - mu)}$ is the distance between a multivariate Gaussian distribution ($mu$, $Sigma$) and a point. If the Gaussian distribution represents a class, we can classify new points by choosing the class with the minimum distance.
I'm giving an N*D trained data as class data, and I need to calculate mu and inverse of Sigma.
Estimates the parameters for the mahalanobis distance for a specific class.
:param x_class: a (n x d) numpy array, containing n samples with d features coresponding to a specific class.
:return: tuple of (mu, inv_Si)
where mu is a (d,) numpy array
inv_Si is a (d, d) numpy array.
linear-algebra python mahalanobis-distance
$endgroup$
add a comment |
$begingroup$
Roughly speaking, the Mahalanobis distance $d(x) = sqrt{(x - mu)^T * Sigma^{-1} * (x - mu)}$ is the distance between a multivariate Gaussian distribution ($mu$, $Sigma$) and a point. If the Gaussian distribution represents a class, we can classify new points by choosing the class with the minimum distance.
I'm giving an N*D trained data as class data, and I need to calculate mu and inverse of Sigma.
Estimates the parameters for the mahalanobis distance for a specific class.
:param x_class: a (n x d) numpy array, containing n samples with d features coresponding to a specific class.
:return: tuple of (mu, inv_Si)
where mu is a (d,) numpy array
inv_Si is a (d, d) numpy array.
linear-algebra python mahalanobis-distance
$endgroup$
1
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46
add a comment |
$begingroup$
Roughly speaking, the Mahalanobis distance $d(x) = sqrt{(x - mu)^T * Sigma^{-1} * (x - mu)}$ is the distance between a multivariate Gaussian distribution ($mu$, $Sigma$) and a point. If the Gaussian distribution represents a class, we can classify new points by choosing the class with the minimum distance.
I'm giving an N*D trained data as class data, and I need to calculate mu and inverse of Sigma.
Estimates the parameters for the mahalanobis distance for a specific class.
:param x_class: a (n x d) numpy array, containing n samples with d features coresponding to a specific class.
:return: tuple of (mu, inv_Si)
where mu is a (d,) numpy array
inv_Si is a (d, d) numpy array.
linear-algebra python mahalanobis-distance
$endgroup$
Roughly speaking, the Mahalanobis distance $d(x) = sqrt{(x - mu)^T * Sigma^{-1} * (x - mu)}$ is the distance between a multivariate Gaussian distribution ($mu$, $Sigma$) and a point. If the Gaussian distribution represents a class, we can classify new points by choosing the class with the minimum distance.
I'm giving an N*D trained data as class data, and I need to calculate mu and inverse of Sigma.
Estimates the parameters for the mahalanobis distance for a specific class.
:param x_class: a (n x d) numpy array, containing n samples with d features coresponding to a specific class.
:return: tuple of (mu, inv_Si)
where mu is a (d,) numpy array
inv_Si is a (d, d) numpy array.
linear-algebra python mahalanobis-distance
linear-algebra python mahalanobis-distance
asked Jan 7 at 22:31
andre ahmedandre ahmed
61
61
1
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46
add a comment |
1
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46
1
1
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3065584%2fcalculating-mahalanobis-parameters-from-x-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3065584%2fcalculating-mahalanobis-parameters-from-x-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
What are your thoughts? What have you tried? You cannot "calculate" these parameters, you can only estimate them from data. Which estimator are you using? MLE?
$endgroup$
– angryavian
Jan 7 at 22:39
$begingroup$
@angryavian I didn't think about any estimator.. didn't even understand the problem. Can you show me how to estimate them using MLE for example ?
$endgroup$
– andre ahmed
Jan 7 at 22:42
$begingroup$
I'm using EmpiricalCovariance, I get correct mu but inverse of covariance is wrong
$endgroup$
– andre ahmed
Jan 7 at 23:46