def testLogConditionalProbability(self): """Test log_conditional_probability()""" obtained = direct_confirmation_measure.log_conditional_probability( self.segmentation, self.accumulator)[0] # Answer should be ~ ln(1 / 2) = -0.693147181 expected = -0.693147181 self.assertAlmostEqual(expected, obtained) mean, std = direct_confirmation_measure.log_conditional_probability( self.segmentation, self.accumulator, with_std=True)[0] self.assertAlmostEqual(expected, mean) self.assertEqual(0.0, std)
def testLogConditionalProbability(self): """Test log_conditional_probability()""" obtained = direct_confirmation_measure.log_conditional_probability( self.segmentation, self.posting_list, self.num_docs)[0] # Answer should be ~ ln(1 / 2) = -0.693147181 expected = -0.693147181 self.assertAlmostEqual(obtained, expected)
continue tupl = (w1, w2) unsegmented_topic.append(w1) segmented_topic.append(tupl) segmented_topics.append(segmented_topic) unsegmented_topics.append(unsegmented_topic) segmented_topic = [] unsegmented_topic = [] #Make accumulator accumulator = probability_estimation.p_boolean_document( corpus, segmented_topics) #Perform the measurements and print results lcp = direct_confirmation_measure.log_conditional_probability( segmented_topics, accumulator) with codecs.open(outputfile1, encoding='utf-8', mode='w', errors='ignore') as outputFile: for item in lcp: outputFile.write('%s \n' % (item)) pmi = direct_confirmation_measure.log_ratio_measure( segmented_topics, accumulator) with codecs.open(outputfile2, encoding='utf-8', mode='w', errors='ignore') as outputFile: for item in pmi: outputFile.write('%s \n' % (item)) cosim = indirect_confirmation_measure.cosine_similarity(
def testLogConditionalProbability(self): """Test log_conditional_probability()""" obtained = direct_confirmation_measure.log_conditional_probability(self.segmentation, self.posting_list, self.num_docs)[0] # Answer should be ~ ln(1 / 2) = -0.693147181 expected = -0.693147181 self.assertAlmostEqual(obtained, expected)