Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model_ug_dmm = Doc2Vec.load('d2v_model_ug_dmm.doc2vec')
- model_ug_dmm.delete_temporary_training_data(keep_doctags_vectors=True, keep_inference=True)
- def get_w2v_ugdbowdmm(tweet, size):
- vec = np.zeros(size).reshape((1, size))
- count = 0.
- for word in tweet.split():
- try:
- vec += np.append(model_ug_dbow[word],model_ug_dmm[word]).reshape((1, size))
- count += 1.
- except KeyError:
- continue
- if count != 0:
- vec /= count
- return vec
- train_vecs_w2v_dbowdmm = np.concatenate([get_w2v_ugdbowdmm(z, 200) for z in x_train])
- validation_vecs_w2v_dbowdmm = np.concatenate([get_w2v_ugdbowdmm(z, 200) for z in x_validation])
- clf = LogisticRegression()
- clf.fit(train_vecs_w2v_dbowdmm, y_train)
- clf.score(validation_vecs_w2v_dbowdmm, y_validation)
Add Comment
Please, Sign In to add comment