chap0lin commited on
Commit
0078548
1 Parent(s): fcae38f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -33
app.py CHANGED
@@ -115,39 +115,39 @@ def classify(df, new_column = True):
115
 
116
  print(sentencesMCTIList_xp8[0])
117
  print("##########################")
118
- print(formatted_sentences[0])
119
-
120
- # print("Transformado em W2V")
121
- # words = list(reloaded_w2v_model.wv.vocab)
122
- # item_shape = np.shape(reloaded_w2v_model.wv[words[0]])
123
- # # print(formatted_sentences)
124
-
125
- # MCTIinput_vector = []
126
- # for sentence in formatted_sentences:
127
- # aux_vector = []
128
- # for word in sentence:
129
- # if word in reloaded_w2v_model.wv.vocab:
130
- # aux_vector.append(reloaded_w2v_model.wv[word])
131
- # else:
132
- # aux_vector.append(np.zeros(item_shape))
133
- # MCTIinput_vector.append(aux_vector)
134
- # del formatted_sentences
135
- # print("Convertido W2V")
136
- # MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
137
- # del MCTIinput_vector
138
- # print("Sentenças com Padding")
139
- # print(len(MCTIinput_padded))
140
- # print(len(MCTIinput_padded[0]))
141
- # predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
142
- # del MCTIinput_padded
143
- # print(predictions)
144
-
145
- # cleaned_up_predictions = []
146
- # for prediction in predictions:
147
- # cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
148
- # del predictions
149
-
150
- # df['classification'] = cleaned_up_predictions
151
  return df
152
 
153
  def gen_output(data):
 
115
 
116
  print(sentencesMCTIList_xp8[0])
117
  print("##########################")
118
+ print(formatted_sentences[0][0])
119
+
120
+ print("Transformado em W2V")
121
+ words = list(reloaded_w2v_model.wv.vocab)
122
+ item_shape = np.shape(reloaded_w2v_model.wv[words[0]])
123
+ # print(formatted_sentences)
124
+
125
+ MCTIinput_vector = []
126
+ for sentence in formatted_sentences:
127
+ aux_vector = []
128
+ for word in sentence:
129
+ if word in reloaded_w2v_model.wv.vocab:
130
+ aux_vector.append(reloaded_w2v_model.wv[word])
131
+ else:
132
+ aux_vector.append(np.zeros(item_shape))
133
+ MCTIinput_vector.append(aux_vector)
134
+ del formatted_sentences
135
+ print("Convertido W2V")
136
+ MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
137
+ del MCTIinput_vector
138
+ print("Sentenças com Padding")
139
+ print(len(MCTIinput_padded))
140
+ print(len(MCTIinput_padded[0]))
141
+ predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
142
+ del MCTIinput_padded
143
+ print(predictions)
144
+
145
+ cleaned_up_predictions = []
146
+ for prediction in predictions:
147
+ cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
148
+ del predictions
149
+
150
+ df['classification'] = cleaned_up_predictions
151
  return df
152
 
153
  def gen_output(data):