naive-bayess solution

This commit is contained in:
dylodylo 2020-03-29 21:22:20 +02:00
parent 2a9ca866c9
commit 744e5db758
3 changed files with 10435 additions and 10426 deletions

File diff suppressed because it is too large Load Diff

View File

@ -92,9 +92,9 @@ def predict_post_class(posts, sprob, pprob, word_logprobs):
#print(total_p_prob) #print(total_p_prob)
#print(total_s_prob) #print(total_s_prob)
if total_p_prob > total_s_prob: if total_p_prob > total_s_prob:
out_classes.append(['P', total_s_prob, total_p_prob]) out_classes.append('P')
else: else:
out_classes.append(['S', total_s_prob, total_p_prob]) out_classes.append('S')
return out_classes return out_classes
@ -109,3 +109,12 @@ def predict_posts(path):
predict_posts("dev-0") predict_posts("dev-0")
predict_posts("test-A") predict_posts("test-A")
with open("dev-0/out.tsv") as out_file, open("dev-0/expected.tsv") as exp_file:
counter = 0
positive = 0
for out_line, exp_line in zip(out_file, exp_file):
counter+=1
if " "+out_line == exp_line:
positive += 1
print(positive/counter)

File diff suppressed because it is too large Load Diff