Я хочу использовать word2vec с tfidf для набора данных отзывов amazon, но я не могу понять, как это сделать .... Я выбрал данные, которые содержат 5k обзоров с положительным баллом и 5k отрицательным баллом ....... есть оценка по столбцу, которая соответствует + ve или -ve.я пытался, но у меня есть следующие ошибки ......
#TF-IDF
final_tf_idf = tf_idf_vect.fit_transform(final_data['CleanedText'].values)
tfidf_feat = tf_idf_vect.get_feature_names()
# tfidf words/col-names
# final_tf_idf is the sparse matrix with row= sentence, col=word and cell_val = tfidf
tfidf_sent_vectors = []; # the tfidf-w2v for each sentence/review is stored in this list
row=0;
for sent in list_of_sent: # for each review/sentence
sent_vec = np.zeros(50) # as word vectors are of zero length
weight_sum =0; # num of words with a valid vector in the sentence/review
for word in sent: # for each word in a review/sentence
try:
vec = w2v_model.wv[word]
# obtain the tf_idfidf of a word in a sentence/review
tfidf = X[row, tfidf_feat.index(word)]
sent_vec += (vec * tfidf)
weight_sum += tfidf
except:
pass
sent_vec /= weight_sum
print(np.isnan(np.sum(sent_vec)))
tfidf_sent_vectors.append(sent_vec)
row += 1
Ошибка: недопустимое значение, встречающееся в true_divide, похоже, что у меня есть значения NaN в каждой строке sent_vec
Anyбыла бы признательна за помощь ... !!