Gaetano Parente commited on
Commit
db62dd1
·
1 Parent(s): 52f8e1a

fix binary-classification

Browse files
data/model/binary-classification.h5 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:9570c076603ee591b4bdf5aee6fd033b87ba757f9438a45ce3171a880a871a39
3
- size 204632
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82b3dbcc96b85747d1dac74332dd09544f72bf4d0699aae158cabbd61610c3bb
3
+ size 1762032
modules/binary_classification.py CHANGED
@@ -55,7 +55,7 @@ def predict_sentiment(review, vocab, tokenizer, model):
55
  # convert to line
56
  line = ' '.join(tokens)
57
  # encode
58
- encoded = tokenizer.texts_to_matrix([line], mode='tfidf')
59
  # predict sentiment
60
  yhat = model.predict(encoded, verbose=0)
61
  # retrieve predicted percentage and label
@@ -89,11 +89,11 @@ def binary_classification(text):
89
  positive = 0
90
  negative = 0
91
  if(sentiment == 'POSITIVE'):
92
- positive = percent
93
- negative = 100 - percent.astype(float)
94
  else:
95
- negative = percent
96
- positive = 100 - percent.astype(float)
97
  labels = {
98
  'positive' : "%.2f" % float(positive/100),
99
  'negative' : "%.2f" % float(negative/100)
 
55
  # convert to line
56
  line = ' '.join(tokens)
57
  # encode
58
+ encoded = tokenizer.texts_to_matrix([line], mode='freq')
59
  # predict sentiment
60
  yhat = model.predict(encoded, verbose=0)
61
  # retrieve predicted percentage and label
 
89
  positive = 0
90
  negative = 0
91
  if(sentiment == 'POSITIVE'):
92
+ positive = percent.astype(float) * 100
93
+ negative = 100 - positive
94
  else:
95
+ negative = percent.astype(float) * 100
96
+ positive = 100 - negative
97
  labels = {
98
  'positive' : "%.2f" % float(positive/100),
99
  'negative' : "%.2f" % float(negative/100)