Sambhavnoobcoder commited on
Commit
5f8d01c
·
1 Parent(s): e5c3564

ok , so my model was giving negative answer fro both good and bad , so now I ma testing another model.

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -39,7 +39,7 @@ with open('tokenizer.json', 'r', encoding='utf-8') as f:
39
 
40
  tokenizer = tokenizer_from_json(tokenizer_config)
41
 
42
- model = tf.keras.models.load_model("sentimentality.h5", custom_objects={'f1':f1, 'recall': recall, 'precision': precision, 'accuracy':accuracy})
43
 
44
  def get_sentiment(text):
45
  global model
@@ -51,8 +51,8 @@ def get_sentiment(text):
51
  text = [stemmer.lemmatize(word) for word in text]
52
  text = ' '.join(text)
53
  text = tokenizer.texts_to_sequences([text])[0]
54
- text += [0] * (30 - len(text))
55
- text = np.array(text).reshape(-1, 30)
56
  x = model.predict(text).tolist()[0][0]
57
  return ('Positive' if x >= 0.5 else 'negative') + ' sentiment!'
58
 
 
39
 
40
  tokenizer = tokenizer_from_json(tokenizer_config)
41
 
42
+ model = tf.keras.models.load_model("model_RNN.h5", custom_objects={'f1':f1, 'recall': recall, 'precision': precision, 'accuracy':accuracy})
43
 
44
  def get_sentiment(text):
45
  global model
 
51
  text = [stemmer.lemmatize(word) for word in text]
52
  text = ' '.join(text)
53
  text = tokenizer.texts_to_sequences([text])[0]
54
+ text += [0] * (200 - len(text))
55
+ text = np.array(text).reshape(-1, 200)
56
  x = model.predict(text).tolist()[0][0]
57
  return ('Positive' if x >= 0.5 else 'negative') + ' sentiment!'
58