Skip to content

Commit

Permalink
a3: Use base 2 instead of base e in nbm.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
marklang1993 committed Jun 30, 2017
1 parent a02aebd commit 2c87998
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Binary file modified a3/assignment3_ChenLang.docx
Binary file not shown.
Binary file modified a3/assignment3_ChenLang.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions a3/nbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 185,8 @@ def list_top10(self):
# calculate
for attr_idx in result_idx:
result_val[attr_idx] = abs(\
math.log(self.factors_pos[attr_idx].get_p_pos()) -\
math.log(self.factors_neg[attr_idx].get_p_pos()))
math.log(self.factors_pos[attr_idx].get_p_pos(), 2) -\
math.log(self.factors_neg[attr_idx].get_p_pos(), 2))
# sort
self.sort_idxval(result_idx, result_val)
# print
Expand Down
20 changes: 10 additions & 10 deletions a3/nbm_result.txt
Original file line number Diff line number Diff line change
@@ -1,13 1,13 @@
No. 0 : 3143 , 4.42487744454 , graphics
No. 1 : 3 , 3.97443270622 , atheism
No. 2 : 17 , 3.92791269058 , religion
No. 3 : 426 , 3.85380471843 , moral
No. 4 : 768 , 3.85380471843 , evidence
No. 5 : 571 , 3.85380471843 , keith
No. 6 : 563 , 3.82782923203 , atheists
No. 7 : 212 , 3.78297866586 , god
No. 8 : 74 , 3.74559113379 , bible
No. 9 : 272 , 3.71660359692 , christian
No. 0 : 3143 , 6.38374874578 , graphics
No. 1 : 3 , 5.73389435561 , atheism
No. 2 : 17 , 5.66678015975 , religion
No. 3 : 426 , 5.55986495583 , moral
No. 4 : 768 , 5.55986495583 , evidence
No. 5 : 571 , 5.55986495583 , keith
No. 6 : 563 , 5.52239025041 , atheists
No. 7 : 212 , 5.45768456103 , god
No. 8 : 74 , 5.40374575392 , bible
No. 9 : 272 , 5.36192557822 , christian
Test result:
Pass / Fail : 629 / 78
Accuracy: 88.9674681754
Expand Down

0 comments on commit 2c87998

Please sign in to comment.