naive-bayess solution
This commit is contained in:
parent
2a9ca866c9
commit
744e5db758
10544
dev-0/out.tsv
10544
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
13
solution.py
13
solution.py
@ -92,9 +92,9 @@ def predict_post_class(posts, sprob, pprob, word_logprobs):
|
||||
#print(total_p_prob)
|
||||
#print(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:
|
||||
out_classes.append(['S', total_s_prob, total_p_prob])
|
||||
out_classes.append('S')
|
||||
|
||||
return out_classes
|
||||
|
||||
@ -109,3 +109,12 @@ def predict_posts(path):
|
||||
|
||||
predict_posts("dev-0")
|
||||
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)
|
10304
test-A/out.tsv
10304
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user