Find the list that best matches reference list
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I need to find how well several different lists match a reference list. I'm looking for a percentage or some kind of similarity score.
For example,
a = "A278", "G279", "S280", "G281", "I282", "I283", "I284", "S285",
"D286", "T287", "P288", "V289", "H290", "D291", "C292"
b = "S280", "G281", "I282", "I284"
c = "C275", "S276", "T277", "A278", "G279"
How can I determine that b
is a better match against a
than c
? a
is the reference list.
Order matters.
After looking through the documentation, the only way I can think of doing this is to iterate through b
and c
and test if each element is MemberQ
of a
, tallying up the total and comparing the totals at the end. Is there a better approach?
list-manipulation
add a comment |Â
up vote
2
down vote
favorite
I need to find how well several different lists match a reference list. I'm looking for a percentage or some kind of similarity score.
For example,
a = "A278", "G279", "S280", "G281", "I282", "I283", "I284", "S285",
"D286", "T287", "P288", "V289", "H290", "D291", "C292"
b = "S280", "G281", "I282", "I284"
c = "C275", "S276", "T277", "A278", "G279"
How can I determine that b
is a better match against a
than c
? a
is the reference list.
Order matters.
After looking through the documentation, the only way I can think of doing this is to iterate through b
and c
and test if each element is MemberQ
of a
, tallying up the total and comparing the totals at the end. Is there a better approach?
list-manipulation
You might consider looking through the whole bunch of*Distance
/*Dissimilarity
functions available.SequenceAlignment
might also be of use.
â J. M. is somewhat okay.â¦
1 hour ago
1
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, considerComplement
.
â bbgodfrey
1 hour ago
Working onComplement
now, it seems promising @bbgodfrey
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to find how well several different lists match a reference list. I'm looking for a percentage or some kind of similarity score.
For example,
a = "A278", "G279", "S280", "G281", "I282", "I283", "I284", "S285",
"D286", "T287", "P288", "V289", "H290", "D291", "C292"
b = "S280", "G281", "I282", "I284"
c = "C275", "S276", "T277", "A278", "G279"
How can I determine that b
is a better match against a
than c
? a
is the reference list.
Order matters.
After looking through the documentation, the only way I can think of doing this is to iterate through b
and c
and test if each element is MemberQ
of a
, tallying up the total and comparing the totals at the end. Is there a better approach?
list-manipulation
I need to find how well several different lists match a reference list. I'm looking for a percentage or some kind of similarity score.
For example,
a = "A278", "G279", "S280", "G281", "I282", "I283", "I284", "S285",
"D286", "T287", "P288", "V289", "H290", "D291", "C292"
b = "S280", "G281", "I282", "I284"
c = "C275", "S276", "T277", "A278", "G279"
How can I determine that b
is a better match against a
than c
? a
is the reference list.
Order matters.
After looking through the documentation, the only way I can think of doing this is to iterate through b
and c
and test if each element is MemberQ
of a
, tallying up the total and comparing the totals at the end. Is there a better approach?
list-manipulation
list-manipulation
asked 2 hours ago
briennakh
2998
2998
You might consider looking through the whole bunch of*Distance
/*Dissimilarity
functions available.SequenceAlignment
might also be of use.
â J. M. is somewhat okay.â¦
1 hour ago
1
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, considerComplement
.
â bbgodfrey
1 hour ago
Working onComplement
now, it seems promising @bbgodfrey
â briennakh
1 hour ago
add a comment |Â
You might consider looking through the whole bunch of*Distance
/*Dissimilarity
functions available.SequenceAlignment
might also be of use.
â J. M. is somewhat okay.â¦
1 hour ago
1
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, considerComplement
.
â bbgodfrey
1 hour ago
Working onComplement
now, it seems promising @bbgodfrey
â briennakh
1 hour ago
You might consider looking through the whole bunch of
*Distance
/*Dissimilarity
functions available. SequenceAlignment
might also be of use.â J. M. is somewhat okay.â¦
1 hour ago
You might consider looking through the whole bunch of
*Distance
/*Dissimilarity
functions available. SequenceAlignment
might also be of use.â J. M. is somewhat okay.â¦
1 hour ago
1
1
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, consider
Complement
.â bbgodfrey
1 hour ago
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, consider
Complement
.â bbgodfrey
1 hour ago
Working on
Complement
now, it seems promising @bbgodfreyâ briennakh
1 hour ago
Working on
Complement
now, it seems promising @bbgodfreyâ briennakh
1 hour ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
2
down vote
Going off your percent similarity idea, maybe something like
listsim[ref_, test_] := #, 100. (1 - Length@Complement[ref, #]/Length@ref) & /@ test
listsim[a, a, b, c]
A278,G279,S280,G281,I282,I283,I284,S285,D286,T287,P288,V289,H290,D291,C292,100.
S280,G281,I282,I284,26.6667
C275,S276,T277,A278,G279,13.3333
which ended up being in a similar vein to your answer.
I like this!! Thanks!
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
MaximalBy[Length[aâÂÂ#]&]@b,c
"S280", "G281", "I282", "I284"
MinimalBy[Length@Complement[a,#]&]@b,c
"S280", "G281", "I282", "I284"
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
add a comment |Â
up vote
1
down vote
Suppose I have the reference list a
and a matrix otherLists
of all other lists I want to compare against a
:
otherLists[[Ordering[Length[#] & /@ (Complement[a, #] & /@ otherLists), 1]]]
This will return the list that best matches a
.
you can use justLength
instead ofLength[#] &
.
â kglr
55 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Going off your percent similarity idea, maybe something like
listsim[ref_, test_] := #, 100. (1 - Length@Complement[ref, #]/Length@ref) & /@ test
listsim[a, a, b, c]
A278,G279,S280,G281,I282,I283,I284,S285,D286,T287,P288,V289,H290,D291,C292,100.
S280,G281,I282,I284,26.6667
C275,S276,T277,A278,G279,13.3333
which ended up being in a similar vein to your answer.
I like this!! Thanks!
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
Going off your percent similarity idea, maybe something like
listsim[ref_, test_] := #, 100. (1 - Length@Complement[ref, #]/Length@ref) & /@ test
listsim[a, a, b, c]
A278,G279,S280,G281,I282,I283,I284,S285,D286,T287,P288,V289,H290,D291,C292,100.
S280,G281,I282,I284,26.6667
C275,S276,T277,A278,G279,13.3333
which ended up being in a similar vein to your answer.
I like this!! Thanks!
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Going off your percent similarity idea, maybe something like
listsim[ref_, test_] := #, 100. (1 - Length@Complement[ref, #]/Length@ref) & /@ test
listsim[a, a, b, c]
A278,G279,S280,G281,I282,I283,I284,S285,D286,T287,P288,V289,H290,D291,C292,100.
S280,G281,I282,I284,26.6667
C275,S276,T277,A278,G279,13.3333
which ended up being in a similar vein to your answer.
Going off your percent similarity idea, maybe something like
listsim[ref_, test_] := #, 100. (1 - Length@Complement[ref, #]/Length@ref) & /@ test
listsim[a, a, b, c]
A278,G279,S280,G281,I282,I283,I284,S285,D286,T287,P288,V289,H290,D291,C292,100.
S280,G281,I282,I284,26.6667
C275,S276,T277,A278,G279,13.3333
which ended up being in a similar vein to your answer.
edited 1 hour ago
answered 1 hour ago
That Gravity Guy
1,470514
1,470514
I like this!! Thanks!
â briennakh
1 hour ago
add a comment |Â
I like this!! Thanks!
â briennakh
1 hour ago
I like this!! Thanks!
â briennakh
1 hour ago
I like this!! Thanks!
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
MaximalBy[Length[aâÂÂ#]&]@b,c
"S280", "G281", "I282", "I284"
MinimalBy[Length@Complement[a,#]&]@b,c
"S280", "G281", "I282", "I284"
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
add a comment |Â
up vote
2
down vote
MaximalBy[Length[aâÂÂ#]&]@b,c
"S280", "G281", "I282", "I284"
MinimalBy[Length@Complement[a,#]&]@b,c
"S280", "G281", "I282", "I284"
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
MaximalBy[Length[aâÂÂ#]&]@b,c
"S280", "G281", "I282", "I284"
MinimalBy[Length@Complement[a,#]&]@b,c
"S280", "G281", "I282", "I284"
MaximalBy[Length[aâÂÂ#]&]@b,c
"S280", "G281", "I282", "I284"
MinimalBy[Length@Complement[a,#]&]@b,c
"S280", "G281", "I282", "I284"
edited 43 mins ago
answered 1 hour ago
kglr
164k8188388
164k8188388
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
add a comment |Â
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
+1 for conciseness, this is better than my answer
â briennakh
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
@briennakh, yours is probably faster.
â kglr
1 hour ago
add a comment |Â
up vote
1
down vote
Suppose I have the reference list a
and a matrix otherLists
of all other lists I want to compare against a
:
otherLists[[Ordering[Length[#] & /@ (Complement[a, #] & /@ otherLists), 1]]]
This will return the list that best matches a
.
you can use justLength
instead ofLength[#] &
.
â kglr
55 mins ago
add a comment |Â
up vote
1
down vote
Suppose I have the reference list a
and a matrix otherLists
of all other lists I want to compare against a
:
otherLists[[Ordering[Length[#] & /@ (Complement[a, #] & /@ otherLists), 1]]]
This will return the list that best matches a
.
you can use justLength
instead ofLength[#] &
.
â kglr
55 mins ago
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Suppose I have the reference list a
and a matrix otherLists
of all other lists I want to compare against a
:
otherLists[[Ordering[Length[#] & /@ (Complement[a, #] & /@ otherLists), 1]]]
This will return the list that best matches a
.
Suppose I have the reference list a
and a matrix otherLists
of all other lists I want to compare against a
:
otherLists[[Ordering[Length[#] & /@ (Complement[a, #] & /@ otherLists), 1]]]
This will return the list that best matches a
.
answered 1 hour ago
briennakh
2998
2998
you can use justLength
instead ofLength[#] &
.
â kglr
55 mins ago
add a comment |Â
you can use justLength
instead ofLength[#] &
.
â kglr
55 mins ago
you can use just
Length
instead of Length[#] &
.â kglr
55 mins ago
you can use just
Length
instead of Length[#] &
.â kglr
55 mins ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183342%2ffind-the-list-that-best-matches-reference-list%23new-answer', 'question_page');
);
Post as a guest
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
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
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
You might consider looking through the whole bunch of
*Distance
/*Dissimilarity
functions available.SequenceAlignment
might also be of use.â J. M. is somewhat okay.â¦
1 hour ago
1
Testing as described in the last paragraph of the question does not take account of order. If order actually does not matter, consider
Complement
.â bbgodfrey
1 hour ago
Working on
Complement
now, it seems promising @bbgodfreyâ briennakh
1 hour ago