In [11]:
import math
In [ ]:
idcgs_per_thresh = {
1.0:
}
In [ ]:
term_at_k = {
}
In [9]:
def idcg(thresh):
out = 0;0
for k_minus_1 in range(thresh):
k = k_minus_1 +1
part =
In [34]:
def term_dcg(k):
rel = {
1:1,
2:0,
3:1,
4:1,
5:0,
6:1,
7:0,
8:0
}
return (math.pow(2,rel[k]) - 1.0)/math.log(1+k,2)
In [35]:
n1 = term_dcg(1);n1
Out[35]:
In [36]:
n2=n1+term_dcg(2);n2
Out[36]:
In [37]:
n3=n2+term_dcg(3);n3
Out[37]:
In [38]:
n4=n3+term_dcg(4);n4
Out[38]:
In [39]:
n5=n4+term_dcg(5);n5
Out[39]:
In [40]:
n6=n5+term_dcg(6);n6
Out[40]:
In [41]:
n7 = n6+term_dcg(7);n7
Out[41]:
In [42]:
n8 = n7+term_dcg(8);n8
Out[42]:
In [44]:
def term_idcg(k):
rel = {
1:1,
2:1,
3:1,
4:1,
5:0,
6:0,
7:0,
8:0
}
return (math.pow(2,rel[k]) - 1.0)/math.log(1+k,2)
In [45]:
id1 = term_idcg(1);id1
Out[45]:
In [47]:
id2 = id1+term_idcg(2);id2
Out[47]:
In [48]:
id3 = id2+term_idcg(3);id3
Out[48]:
In [49]:
id4 = id3+term_idcg(4);id4
Out[49]:
In [50]:
id5 = id4+term_idcg(5);id5
Out[50]:
In [51]:
id6 = id5+term_idcg(6);id6
Out[51]:
In [52]:
id7 = id6+term_idcg(7);id7
Out[52]:
In [53]:
id8 = id7+term_idcg(8);id8
Out[53]:
In [55]:
nd1 = n1/id1;nd1
Out[55]:
In [56]:
nd2 = n2/id2;nd2
Out[56]:
In [57]:
nd3 = n3/id3;nd3
Out[57]:
In [58]:
nd4 = n4/id4;nd4
Out[58]:
In [59]:
nd5 = n5/id5;nd5
Out[59]:
In [60]:
nd6 = n6/id6;nd6
Out[60]:
In [67]:
nd7=n7/id7;nd7
Out[67]:
In [69]:
nd8=n8/id8;nd8
Out[69]: