On 7/23/2012 2:11 PM Ali Torkamani said...
Hi All,
I want to count how many (what percentage) of partial orders are
identical in two lists.
You may find SequenceMatcher from module difflib helpful. See
http://docs.python.org/library/difflib.html for info.
Emile
(For example let L1 be the list of ground truth
scores and L2 be the estimated scores for a list of students, I want to
check how many (what percentage) of pairwise orderings (rankings) are
preserved)
I have written the following (inefficient) code, is there anyway in
Python to write it more efficiently?
S=0;
A=0;
n=len(L1)
for i in range(n):
for j in range(i+1,n,1):
A+=1;
if (L1[i]>L1[j] and L2[i]>L2[j]) or (L1[i]<L1[j] and
L2[i]<L2[j]) or (L1[i]==L1[j] and L2[i]==L2[j]):
S+=1
print(100*float(S)/A)
Thanks,
A
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor