Python - Data Encoding Vector To Word












0














I have a code that converts word to vector. Below is my code:



# word_to_vec_demo.py

from gensim.models import word2vec
import logging

logging.basicConfig(format='%(asctime)s :
%(levelname)s : %(message)s', level=logging.INFO)

sentences = [['In', 'the', 'beginning', 'Abba','Yahweh', 'created', 'the',
'heaven', 'and', 'the', 'earth.', 'And', 'the', 'earth', 'was',
'without', 'form,', 'and', 'void;', 'and', 'darkness', 'was',
'upon', 'the', 'face', 'of', 'the', 'deep.', 'And', 'the',
'Spirit', 'of', 'Yahweh', 'moved', 'upon', 'the', 'face', 'of',
'the', 'waters.']]

model = word2vec.Word2Vec(sentences, size=10, min_count=1)

print("Vector for 'earth' is: n")
print(model.wv['earth'])

print("nEnd demo")


The output is



Vector for 'earth' is: 

[-0.00402722 0.0034133 0.01583795 0.01997946 0.04112177 0.00291858
-0.03854967 0.01581967 -0.02399057 0.00539708]


Is it possible to encode from array of vector to words? If yes, how will I implement it in Python?










share|improve this question
























  • You mean from the resulting vectors of Word2Vec?
    – yatu
    Nov 12 '18 at 15:15










  • @AlexandreNixon --> Yes sir. Is it possible?
    – Eliyah
    Nov 12 '18 at 15:18
















0














I have a code that converts word to vector. Below is my code:



# word_to_vec_demo.py

from gensim.models import word2vec
import logging

logging.basicConfig(format='%(asctime)s :
%(levelname)s : %(message)s', level=logging.INFO)

sentences = [['In', 'the', 'beginning', 'Abba','Yahweh', 'created', 'the',
'heaven', 'and', 'the', 'earth.', 'And', 'the', 'earth', 'was',
'without', 'form,', 'and', 'void;', 'and', 'darkness', 'was',
'upon', 'the', 'face', 'of', 'the', 'deep.', 'And', 'the',
'Spirit', 'of', 'Yahweh', 'moved', 'upon', 'the', 'face', 'of',
'the', 'waters.']]

model = word2vec.Word2Vec(sentences, size=10, min_count=1)

print("Vector for 'earth' is: n")
print(model.wv['earth'])

print("nEnd demo")


The output is



Vector for 'earth' is: 

[-0.00402722 0.0034133 0.01583795 0.01997946 0.04112177 0.00291858
-0.03854967 0.01581967 -0.02399057 0.00539708]


Is it possible to encode from array of vector to words? If yes, how will I implement it in Python?










share|improve this question
























  • You mean from the resulting vectors of Word2Vec?
    – yatu
    Nov 12 '18 at 15:15










  • @AlexandreNixon --> Yes sir. Is it possible?
    – Eliyah
    Nov 12 '18 at 15:18














0












0








0







I have a code that converts word to vector. Below is my code:



# word_to_vec_demo.py

from gensim.models import word2vec
import logging

logging.basicConfig(format='%(asctime)s :
%(levelname)s : %(message)s', level=logging.INFO)

sentences = [['In', 'the', 'beginning', 'Abba','Yahweh', 'created', 'the',
'heaven', 'and', 'the', 'earth.', 'And', 'the', 'earth', 'was',
'without', 'form,', 'and', 'void;', 'and', 'darkness', 'was',
'upon', 'the', 'face', 'of', 'the', 'deep.', 'And', 'the',
'Spirit', 'of', 'Yahweh', 'moved', 'upon', 'the', 'face', 'of',
'the', 'waters.']]

model = word2vec.Word2Vec(sentences, size=10, min_count=1)

print("Vector for 'earth' is: n")
print(model.wv['earth'])

print("nEnd demo")


The output is



Vector for 'earth' is: 

[-0.00402722 0.0034133 0.01583795 0.01997946 0.04112177 0.00291858
-0.03854967 0.01581967 -0.02399057 0.00539708]


Is it possible to encode from array of vector to words? If yes, how will I implement it in Python?










share|improve this question















I have a code that converts word to vector. Below is my code:



# word_to_vec_demo.py

from gensim.models import word2vec
import logging

logging.basicConfig(format='%(asctime)s :
%(levelname)s : %(message)s', level=logging.INFO)

sentences = [['In', 'the', 'beginning', 'Abba','Yahweh', 'created', 'the',
'heaven', 'and', 'the', 'earth.', 'And', 'the', 'earth', 'was',
'without', 'form,', 'and', 'void;', 'and', 'darkness', 'was',
'upon', 'the', 'face', 'of', 'the', 'deep.', 'And', 'the',
'Spirit', 'of', 'Yahweh', 'moved', 'upon', 'the', 'face', 'of',
'the', 'waters.']]

model = word2vec.Word2Vec(sentences, size=10, min_count=1)

print("Vector for 'earth' is: n")
print(model.wv['earth'])

print("nEnd demo")


The output is



Vector for 'earth' is: 

[-0.00402722 0.0034133 0.01583795 0.01997946 0.04112177 0.00291858
-0.03854967 0.01581967 -0.02399057 0.00539708]


Is it possible to encode from array of vector to words? If yes, how will I implement it in Python?







python machine-learning nlp gensim word2vec






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 6:17

























asked Nov 12 '18 at 15:12









Eliyah

3431525




3431525












  • You mean from the resulting vectors of Word2Vec?
    – yatu
    Nov 12 '18 at 15:15










  • @AlexandreNixon --> Yes sir. Is it possible?
    – Eliyah
    Nov 12 '18 at 15:18


















  • You mean from the resulting vectors of Word2Vec?
    – yatu
    Nov 12 '18 at 15:15










  • @AlexandreNixon --> Yes sir. Is it possible?
    – Eliyah
    Nov 12 '18 at 15:18
















You mean from the resulting vectors of Word2Vec?
– yatu
Nov 12 '18 at 15:15




You mean from the resulting vectors of Word2Vec?
– yatu
Nov 12 '18 at 15:15












@AlexandreNixon --> Yes sir. Is it possible?
– Eliyah
Nov 12 '18 at 15:18




@AlexandreNixon --> Yes sir. Is it possible?
– Eliyah
Nov 12 '18 at 15:18












1 Answer
1






active

oldest

votes


















2














You can use the similar_by_vector() method from your model to find the top-N most similar words by vector.
Hope this helps.






share|improve this answer





















  • Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
    – Eliyah
    Nov 12 '18 at 15:27






  • 1




    Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
    – yatu
    Nov 12 '18 at 15:55










  • Please consider setting the answer as correct. Thank you.
    – yatu
    Nov 13 '18 at 8:58











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265028%2fpython-data-encoding-vector-to-word%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You can use the similar_by_vector() method from your model to find the top-N most similar words by vector.
Hope this helps.






share|improve this answer





















  • Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
    – Eliyah
    Nov 12 '18 at 15:27






  • 1




    Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
    – yatu
    Nov 12 '18 at 15:55










  • Please consider setting the answer as correct. Thank you.
    – yatu
    Nov 13 '18 at 8:58
















2














You can use the similar_by_vector() method from your model to find the top-N most similar words by vector.
Hope this helps.






share|improve this answer





















  • Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
    – Eliyah
    Nov 12 '18 at 15:27






  • 1




    Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
    – yatu
    Nov 12 '18 at 15:55










  • Please consider setting the answer as correct. Thank you.
    – yatu
    Nov 13 '18 at 8:58














2












2








2






You can use the similar_by_vector() method from your model to find the top-N most similar words by vector.
Hope this helps.






share|improve this answer












You can use the similar_by_vector() method from your model to find the top-N most similar words by vector.
Hope this helps.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 15:22









yatu

5,1961423




5,1961423












  • Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
    – Eliyah
    Nov 12 '18 at 15:27






  • 1




    Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
    – yatu
    Nov 12 '18 at 15:55










  • Please consider setting the answer as correct. Thank you.
    – yatu
    Nov 13 '18 at 8:58


















  • Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
    – Eliyah
    Nov 12 '18 at 15:27






  • 1




    Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
    – yatu
    Nov 12 '18 at 15:55










  • Please consider setting the answer as correct. Thank you.
    – yatu
    Nov 13 '18 at 8:58
















Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
– Eliyah
Nov 12 '18 at 15:27




Thanks , I have one additional question, can I use wordtovector to train my neural network? See my stackoverflow.com/questions/52982719/…
– Eliyah
Nov 12 '18 at 15:27




1




1




Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
– yatu
Nov 12 '18 at 15:55




Yes. If you want to train a deep learning model with text you must feed it with some word embedding or encoding of the input data.
– yatu
Nov 12 '18 at 15:55












Please consider setting the answer as correct. Thank you.
– yatu
Nov 13 '18 at 8:58




Please consider setting the answer as correct. Thank you.
– yatu
Nov 13 '18 at 8:58


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265028%2fpython-data-encoding-vector-to-word%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues