Example #1
0
 def testExploitativeProbabilisticInterleaveTwoDocs(self):
     # prepare rankers
     r1 = ProbabilisticRankingFunction(1, self.weights_1)
     r2 = ProbabilisticRankingFunction(1, self.weights_2)
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(1)
     r2.rm_document(1)
     r1.rm_document(3)
     r2.rm_document(3)
     # test after 1 and 3 were removed
     epi = ExploitativeProbabilisticInterleave("--exploration_rate=0.5")
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [0, 2]
     exp_probs = [0.61428571, 0.38571429]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)
Example #2
0
 def testExploitativeProbabilisticInterleaveTwoDocs(self):
     # prepare rankers
     r1 = ProbabilisticRankingFunction(1, self.weights_1)
     r2 = ProbabilisticRankingFunction(1, self.weights_2)
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(1)
     r2.rm_document(1)
     r1.rm_document(3)
     r2.rm_document(3)
     # test after 1 and 3 were removed
     epi = ExploitativeProbabilisticInterleave("--exploration_rate=0.5")
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [0, 2]
     exp_probs = [0.61428571, 0.38571429]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)
Example #3
0
 def testExploitativeProbabilisticInterleaveThreeDocs(self):
     epi = ExploitativeProbabilisticInterleave("--exploration_rate=0.5")
     # prepare rankers
     r1 = ProbabilisticRankingFunction(1, self.weights_1)
     r2 = ProbabilisticRankingFunction(1, self.weights_2)
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(0)
     r2.rm_document(0)
     # test after document 0 was removed
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [1, 3, 2]
     exp_probs = [0.5034965, 0.29020979, 0.20629371]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)
     # prepare rankers
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(3)
     r2.rm_document(3)
     # test after document 3 was removed
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [1, 0, 2]
     exp_probs = [0.45864662, 0.36466165, 0.17669173]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)
Example #4
0
 def testExploitativeProbabilisticInterleaveThreeDocs(self):
     epi = ExploitativeProbabilisticInterleave("--exploration_rate=0.5")
     # prepare rankers
     r1 = ProbabilisticRankingFunction(1, self.weights_1)
     r2 = ProbabilisticRankingFunction(1, self.weights_2)
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(0)
     r2.rm_document(0)
     # test after document 0 was removed
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [1, 3, 2]
     exp_probs = [0.5034965, 0.29020979, 0.20629371]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)
     # prepare rankers
     r1.init_ranking(self.query)
     r2.init_ranking(self.query)
     r1.rm_document(3)
     r2.rm_document(3)
     # test after document 3 was removed
     (docids, probs) = epi._get_document_distribution(r1, r2)
     exp_docids = [1, 0, 2]
     exp_probs = [0.45864662, 0.36466165, 0.17669173]
     self._prob_doc_test_helper(docids, exp_docids, probs, exp_probs)