Jaccard index, matrix notation
$begingroup$
I have a matrix with rows representing events and columns representing users. The elements of the matrix are binary values indicating if a user has attended the event or not.
begin{bmatrix}1&1&0&1&1\1&1&0&0&1\ 1&0&0&1&1end{bmatrix}
I need matrix notation to compute the Jaccard distances between users.
begin{align}
J(U_1,U_2)=frac{|U_1cap U_2|}{|U_1cup U_2|}
end{align}
To compute the numerator I can use the matrix operation
begin{align}
A^Ttimes A
end{align}
Now my question is how to get the denominator of Jaccard index using the matrix notation.
matrices
$endgroup$
add a comment |
$begingroup$
I have a matrix with rows representing events and columns representing users. The elements of the matrix are binary values indicating if a user has attended the event or not.
begin{bmatrix}1&1&0&1&1\1&1&0&0&1\ 1&0&0&1&1end{bmatrix}
I need matrix notation to compute the Jaccard distances between users.
begin{align}
J(U_1,U_2)=frac{|U_1cap U_2|}{|U_1cup U_2|}
end{align}
To compute the numerator I can use the matrix operation
begin{align}
A^Ttimes A
end{align}
Now my question is how to get the denominator of Jaccard index using the matrix notation.
matrices
$endgroup$
add a comment |
$begingroup$
I have a matrix with rows representing events and columns representing users. The elements of the matrix are binary values indicating if a user has attended the event or not.
begin{bmatrix}1&1&0&1&1\1&1&0&0&1\ 1&0&0&1&1end{bmatrix}
I need matrix notation to compute the Jaccard distances between users.
begin{align}
J(U_1,U_2)=frac{|U_1cap U_2|}{|U_1cup U_2|}
end{align}
To compute the numerator I can use the matrix operation
begin{align}
A^Ttimes A
end{align}
Now my question is how to get the denominator of Jaccard index using the matrix notation.
matrices
$endgroup$
I have a matrix with rows representing events and columns representing users. The elements of the matrix are binary values indicating if a user has attended the event or not.
begin{bmatrix}1&1&0&1&1\1&1&0&0&1\ 1&0&0&1&1end{bmatrix}
I need matrix notation to compute the Jaccard distances between users.
begin{align}
J(U_1,U_2)=frac{|U_1cap U_2|}{|U_1cup U_2|}
end{align}
To compute the numerator I can use the matrix operation
begin{align}
A^Ttimes A
end{align}
Now my question is how to get the denominator of Jaccard index using the matrix notation.
matrices
matrices
asked Jan 29 '17 at 12:43
MortyMorty
102
102
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Define the vectors
$$eqalign{
b &= A^T1 cr
p &= exp(b) cr
}$$
and the matrices
$$eqalign{
L &= log(pp^T) cr
J &= (A^TA)oslash(L-A^TA) cr
}$$
Note that the log and exp functions are applied elementwise, $oslash$ represents elementwise division, and $1$ is a vector of all ones.
The elements of the $J$-matrix are the Jaccard distances, i.e.
$,,J_{ik} = J(U_i,U_k)$
The third column of your $A$-matrix is problematic since it results in $,J_{33}=frac{0}{0}$
There may be better ways of generating the $L$-matrix. However it is done, its elements must satisfy $$L_{ik} = b_i+b_k$$
Update
A much better way to calculate the $L$-matrix is
$$L = b1^T + 1b^T = A^TU + U^TA$$
where $U$ is a matrix of all ones which has the same shape as $A$.
Now the $J$-matrix can be written as
$$J=(A^TA)oslash(A^TU + U^TA - A^TA)$$
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
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%2f2119199%2fjaccard-index-matrix-notation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Define the vectors
$$eqalign{
b &= A^T1 cr
p &= exp(b) cr
}$$
and the matrices
$$eqalign{
L &= log(pp^T) cr
J &= (A^TA)oslash(L-A^TA) cr
}$$
Note that the log and exp functions are applied elementwise, $oslash$ represents elementwise division, and $1$ is a vector of all ones.
The elements of the $J$-matrix are the Jaccard distances, i.e.
$,,J_{ik} = J(U_i,U_k)$
The third column of your $A$-matrix is problematic since it results in $,J_{33}=frac{0}{0}$
There may be better ways of generating the $L$-matrix. However it is done, its elements must satisfy $$L_{ik} = b_i+b_k$$
Update
A much better way to calculate the $L$-matrix is
$$L = b1^T + 1b^T = A^TU + U^TA$$
where $U$ is a matrix of all ones which has the same shape as $A$.
Now the $J$-matrix can be written as
$$J=(A^TA)oslash(A^TU + U^TA - A^TA)$$
$endgroup$
add a comment |
$begingroup$
Define the vectors
$$eqalign{
b &= A^T1 cr
p &= exp(b) cr
}$$
and the matrices
$$eqalign{
L &= log(pp^T) cr
J &= (A^TA)oslash(L-A^TA) cr
}$$
Note that the log and exp functions are applied elementwise, $oslash$ represents elementwise division, and $1$ is a vector of all ones.
The elements of the $J$-matrix are the Jaccard distances, i.e.
$,,J_{ik} = J(U_i,U_k)$
The third column of your $A$-matrix is problematic since it results in $,J_{33}=frac{0}{0}$
There may be better ways of generating the $L$-matrix. However it is done, its elements must satisfy $$L_{ik} = b_i+b_k$$
Update
A much better way to calculate the $L$-matrix is
$$L = b1^T + 1b^T = A^TU + U^TA$$
where $U$ is a matrix of all ones which has the same shape as $A$.
Now the $J$-matrix can be written as
$$J=(A^TA)oslash(A^TU + U^TA - A^TA)$$
$endgroup$
add a comment |
$begingroup$
Define the vectors
$$eqalign{
b &= A^T1 cr
p &= exp(b) cr
}$$
and the matrices
$$eqalign{
L &= log(pp^T) cr
J &= (A^TA)oslash(L-A^TA) cr
}$$
Note that the log and exp functions are applied elementwise, $oslash$ represents elementwise division, and $1$ is a vector of all ones.
The elements of the $J$-matrix are the Jaccard distances, i.e.
$,,J_{ik} = J(U_i,U_k)$
The third column of your $A$-matrix is problematic since it results in $,J_{33}=frac{0}{0}$
There may be better ways of generating the $L$-matrix. However it is done, its elements must satisfy $$L_{ik} = b_i+b_k$$
Update
A much better way to calculate the $L$-matrix is
$$L = b1^T + 1b^T = A^TU + U^TA$$
where $U$ is a matrix of all ones which has the same shape as $A$.
Now the $J$-matrix can be written as
$$J=(A^TA)oslash(A^TU + U^TA - A^TA)$$
$endgroup$
Define the vectors
$$eqalign{
b &= A^T1 cr
p &= exp(b) cr
}$$
and the matrices
$$eqalign{
L &= log(pp^T) cr
J &= (A^TA)oslash(L-A^TA) cr
}$$
Note that the log and exp functions are applied elementwise, $oslash$ represents elementwise division, and $1$ is a vector of all ones.
The elements of the $J$-matrix are the Jaccard distances, i.e.
$,,J_{ik} = J(U_i,U_k)$
The third column of your $A$-matrix is problematic since it results in $,J_{33}=frac{0}{0}$
There may be better ways of generating the $L$-matrix. However it is done, its elements must satisfy $$L_{ik} = b_i+b_k$$
Update
A much better way to calculate the $L$-matrix is
$$L = b1^T + 1b^T = A^TU + U^TA$$
where $U$ is a matrix of all ones which has the same shape as $A$.
Now the $J$-matrix can be written as
$$J=(A^TA)oslash(A^TU + U^TA - A^TA)$$
edited Dec 9 '18 at 16:39
answered Dec 9 '18 at 3:27
greggreg
7,8701821
7,8701821
add a comment |
add a comment |
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%2f2119199%2fjaccard-index-matrix-notation%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