Find the list that best matches reference list

The name of the pictureThe name of the pictureThe name of the pictureClash 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?










share|improve this question





















  • 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














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?










share|improve this question





















  • 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












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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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, consider Complement.
    – bbgodfrey
    1 hour ago










  • Working on Complement 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







  • 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















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










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.






share|improve this answer






















  • I like this!! Thanks!
    – briennakh
    1 hour ago

















up vote
2
down vote













MaximalBy[Length[a⋂#]&]@b,c 



"S280", "G281", "I282", "I284"




MinimalBy[Length@Complement[a,#]&]@b,c 



"S280", "G281", "I282", "I284"







share|improve this answer






















  • +1 for conciseness, this is better than my answer
    – briennakh
    1 hour ago










  • @briennakh, yours is probably faster.
    – kglr
    1 hour ago

















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.






share|improve this answer




















  • you can use just Length instead of Length[#] &.
    – kglr
    55 mins ago










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: "387"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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.






share|improve this answer






















  • I like this!! Thanks!
    – briennakh
    1 hour ago














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.






share|improve this answer






















  • I like this!! Thanks!
    – briennakh
    1 hour ago












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.






share|improve this 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.







share|improve this answer














share|improve this answer



share|improve this answer








edited 1 hour ago

























answered 1 hour ago









That Gravity Guy

1,470514




1,470514











  • I like this!! Thanks!
    – briennakh
    1 hour ago
















  • I like this!! Thanks!
    – briennakh
    1 hour ago















I like this!! Thanks!
– briennakh
1 hour ago




I like this!! Thanks!
– briennakh
1 hour ago










up vote
2
down vote













MaximalBy[Length[a⋂#]&]@b,c 



"S280", "G281", "I282", "I284"




MinimalBy[Length@Complement[a,#]&]@b,c 



"S280", "G281", "I282", "I284"







share|improve this answer






















  • +1 for conciseness, this is better than my answer
    – briennakh
    1 hour ago










  • @briennakh, yours is probably faster.
    – kglr
    1 hour ago














up vote
2
down vote













MaximalBy[Length[a⋂#]&]@b,c 



"S280", "G281", "I282", "I284"




MinimalBy[Length@Complement[a,#]&]@b,c 



"S280", "G281", "I282", "I284"







share|improve this answer






















  • +1 for conciseness, this is better than my answer
    – briennakh
    1 hour ago










  • @briennakh, yours is probably faster.
    – kglr
    1 hour ago












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"







share|improve this answer














MaximalBy[Length[a⋂#]&]@b,c 



"S280", "G281", "I282", "I284"




MinimalBy[Length@Complement[a,#]&]@b,c 



"S280", "G281", "I282", "I284"








share|improve this answer














share|improve this answer



share|improve this answer








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
















  • +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










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.






share|improve this answer




















  • you can use just Length instead of Length[#] &.
    – kglr
    55 mins ago














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.






share|improve this answer




















  • you can use just Length instead of Length[#] &.
    – kglr
    55 mins ago












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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










answered 1 hour ago









briennakh

2998




2998











  • you can use just Length instead of Length[#] &.
    – 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




you can use just Length instead of Length[#] &.
– kglr
55 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery