Gensim의 'Word2Vec'에 새로 왔습니다. 나는 텍스트 (Wikipedia : Machine Learning에서 추출한)에 대한 Word2Vec 모델을 구축하고 과 유사한 단어을 '기계 학습'으로 찾고 싶습니다.Gensim의 Word2Vec에서 model.most_similar를 사용합니다.
현재 코드는 다음과 같습니다.
# import modules & set up logging
from gensim.models import Word2Vec
sentences = "Machine learning is the subfield of computer science that, according to Arthur Samuel, gives computers the ability to learn without being explicitly programmed.[1][2][verify] Samuel, an American pioneer in the field of computer gaming and artificial intelligence, coined the term machine learning in 1959 while at IBM. Evolved from the study of pattern recognition and computational learning theory in artificial intelligence,[3] machine learning explores the study and construction of algorithms that can learn from and make predictions on data[4] – such algorithms overcome following strictly static program instructions by making data-driven predictions or decisions,[5]:2 through building a model from sample inputs. Machine learning is employed in a range of computing tasks where designing and programming explicit algorithms with good performance is difficult or infeasible; example applications include email filtering, detection of network intruders or malicious insiders working towards a data breach,[6] optical character recognition (OCR),[7] learning to rank, and computer vision."
# train word2vec on the sentences
model = Word2Vec(sentences, min_count=1)
vocab = list(model.wv.vocab.keys())
print(vocab[:10])
그러나 vocab의 경우 한 문자 출력이 표시됩니다.
['M', 'a', 'c', 'h', 'i', 'n', 'e', ' ', 'l', 'r']
model.most_similar
답변 해 주셔서 감사합니다. 모델은 "기계 학습"을 "기계", "학습"으로 보는 단어를 분리함으로써 하나의 해결책으로는 바이 그램을 사용할 수 있지만 그 다음에 3 단어의 단어를 놓칠 수 있습니까? 그런데이 단어 구문은 무엇입니까? –
그런데 split()을 시도했지만 문자 출력으로 문자를 얻습니다. ( –
예, 간단한 토큰 화로 '기계'와 '학습'이 분리됩니다. 'Word2Vec'에 전달되는 토큰을 결정하기 위해 데이터를 사전 처리하는 방법 Gensim은 통계적 빈도에 따라 쌍을 이루는 토큰을 바이그램으로 승격시킬 수있는'Phrases' 클래스를 포함하고 있습니다. 그러나 이것은 Word2Vec 조작과는 별개의 문제입니다 – gojomo