2013-02-23 4 views
2

gensim의 tf-idf 모델이 왜 코퍼스를 변환 한 후에 용어와 카운트를 버리는가?왜 'gensim'의 tf-idf 모델은 내가 코퍼스를 변환 한 후에 용어와 카운트를 버리는가?

내 코드 :

from gensim import corpora, models, similarities 

# Let's say you have a corpus made up of 2 documents. 
doc0 = [(0, 1), (1, 1)] 
doc1 = [(0,1)] 
doc2 = [(0, 1), (1, 1)] 
doc3 = [(0, 3), (1, 1)] 

corpus = [doc0,doc1,doc2,doc3] 

# Train a tfidf model using the corpus 
tfidf = models.TfidfModel(corpus) 

# Now if you print the corpus, it still remains as the flat frequency counts. 
for d in corpus: 
    print d 
print 

# To convert the corpus into tfidf, re-initialize the corpus 
# according to the model to get the normalized frequencies. 
corpus = tfidf[corpus] 

for d in corpus: 
    print d 

출력 : IDF 그 몫의 로그를 가지고 다음 용어를 포함한 문서의 수에 의해 문서의 수를 분할에 의해 얻어지는

[(0, 1.0), (1, 1.0)] 
[(0, 1.0)] 
[(0, 1.0), (1, 1.0)] 
[(0, 3.0), (1, 1.0)] 

[(1, 1.0)] 
[] 
[(1, 1.0)] 
[(1, 1.0)] 

답변

6

. 귀하의 경우 모든 문서는 term0을 가지므로 term0에 대한 IDF는 log (1)이며 0과 같습니다. 따라서 doc-term 행렬에서 term0의 열은 모두 0입니다.

모든 문서에 나타나는 용어는 무게가 0이므로 절대 정보가 없습니다.