Skip to content

Commit

Permalink
ex3 stage 6.0 - some improvement maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriana-Pereira committed Dec 7, 2017
1 parent 4787e53 commit 1d5f55f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ex3/3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.linear_model import Perceptron
from sklearn.naive_bayes import GaussianNB
from sklearn.naive_bayes import MultinomialNB
from sklearn.naive_bayes import BernoulliNB
import functions
import numpy as np
debug = False
Expand Down Expand Up @@ -134,14 +136,14 @@ def train_naive_bayes(train_ft, cl):
if(len(train_ft) != len(cl)):
print("Mismatch summaries and source files\n")
return
model = GaussianNB()
model = MultinomialNB()
model.fit(train_ft, cl)
return model

def get_features_with_NB(model, features):
probs = model.predict_proba(features)
probs = model.predict_log_proba(features)
for i in range(0, len(features)):
features[i].append(probs[i][0])
features[i].append(probs[i][1])
return features


Expand Down
Binary file modified rel.docx
Binary file not shown.

0 comments on commit 1d5f55f

Please sign in to comment.