Esempio n. 1
0
import os
from recsys.evaluation.ranking import AveragePrecision
from recsys.evaluation.ranking import ReciprocalRank
testfile = open("testset_txt_img_cat.list", "r")
resultsfolder = "../Java/Results/"
lines = testfile.xreadlines()
GT = []
ap = AveragePrecision()
rr = ReciprocalRank()
for line in lines:
    GT.append(line.split()[2])
#	GT.append(line.strip())
CCA = resultsfolder
for fname in os.listdir(CCA):
    content = open(CCA + "/" + fname, "r")
    values = content.xreadlines()
    q = []
    for each in values:
        q.append(each.strip())
    sum10 = 0.0
    totmrrsum = 0
    count = 0
    count1 = 0
    for i, j in zip(GT, q):
        num = 0.0
        denom = 1.0
        localsum = 0.0
        q1 = j.split()
        for corr in q1:
            if i == corr:
                num = num + 1.0
 def test_RANK_ReciprocalRank_add_entry(self):
     rr= ReciprocalRank()
     QUERY = 'invented'
     rr.load(self.GT_DECISION, QUERY)
     assert_equal(rr.compute(), 0.0)
Esempio n. 3
0
 def test_RANK_ReciprocalRank_add_entry(self):
     rr = ReciprocalRank()
     QUERY = 'invented'
     rr.load(self.GT_DECISION, QUERY)
     assert_equal(rr.compute(), 0.0)
 def test_RANK_ReciprocalRank_compute(self):
     rr = ReciprocalRank()
     QUERY = 'instrumental'
     assert_equal(rr.compute(self.GT_DECISION, QUERY), 0.5)
Esempio n. 5
0
 def test_RANK_ReciprocalRank_compute(self):
     rr = ReciprocalRank()
     QUERY = 'instrumental'
     assert_equal(rr.compute(self.GT_DECISION, QUERY), 0.5)