chap0lin commited on
Commit
2037e9d
·
1 Parent(s): 3ddaee3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -118,29 +118,29 @@ def classify(df, new_column = True):
118
  print(formatted_sentences)
119
 
120
  MCTIinput_vector = []
121
- # for sentence in formatted_sentences:
122
- # aux_vector = []
123
- # for word in sentence:
124
- # try:
125
- # aux_vector.append(reloaded_w2v_model.wv[word])
126
- # except:
127
- # aux_vector.append(np.zeros(item_shape))
128
- # MCTIinput_vector.append(aux_vector)
129
- # del formatted_sentences
130
-
131
- # MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
132
- # del MCTIinput_vector
133
- # print("Sentenças com Padding")
134
- # predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
135
- # del MCTIinput_padded
136
- # print(predictions)
137
-
138
- # cleaned_up_predictions = []
139
- # for prediction in predictions:
140
- # cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
141
- # del predictions
142
-
143
- # df['classification'] = cleaned_up_predictions
144
  return df
145
 
146
  def gen_output(data):
 
118
  print(formatted_sentences)
119
 
120
  MCTIinput_vector = []
121
+ for sentence in formatted_sentences:
122
+ aux_vector = []
123
+ for word in sentence:
124
+ try:
125
+ aux_vector.append(reloaded_w2v_model.wv[word])
126
+ except:
127
+ aux_vector.append(np.zeros(item_shape))
128
+ MCTIinput_vector.append(aux_vector)
129
+ del formatted_sentences
130
+
131
+ MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
132
+ del MCTIinput_vector
133
+ print("Sentenças com Padding")
134
+ predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
135
+ del MCTIinput_padded
136
+ print(predictions)
137
+
138
+ cleaned_up_predictions = []
139
+ for prediction in predictions:
140
+ cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
141
+ del predictions
142
+
143
+ df['classification'] = cleaned_up_predictions
144
  return df
145
 
146
  def gen_output(data):