2014-01-16 127 views
0

我想知道什麼是尋找大型數據集內的特徵(特殊字)最能接受的方式。當我說特殊詞時,我指的是在特定領域中使用最多的詞。特徵選擇設置

例如,我有兩本書:

  1. BOOK1:一本關於經濟學
  2. 第二冊:一本關於藝術

現在,我選擇BOOK1,並希望看到哪些詞與它最相關。我猜「財務」,「美元」,「收入」等詞彙將佔據最常用單詞列表的首位。即使這些詞也可能出現在book2中,頻率將會低於book1。

在另一方面,在選擇第二冊是應該得到的詞語,如「抽象」,「復興」,「浪漫主義」,「文化」等

當然結果取決於上下文(在上述例如,它取決於book1和book2)。

很明顯,選擇的算法必須能夠消除停止的話。

所以,我想知道這是用於此問題的方法。

回答

1

tf-idf應該幫助,因爲它結合了

  1. 的次數一個詞出現在文檔中(即每本書)
  2. 單詞出現在一組文檔中的次數(a 。K a。語料庫)

如果一個詞出現在文檔中了很多,但沒有這麼多的主體,是對文件的可能特性,將具有較高的TF-IDF得分。另一方面,如果一個詞經常出現在一個文檔中,而且經常出現在整個語料庫中,那麼這個文檔就不是很有特點,並且這個文檔沒有很高的tf-idf分數。每個文檔中具有最高tf-idf度量的詞是最相關的。

停止詞刪除可能是你想要想獲得TF-IDF措施,您的文件之前,對數據進行了一步,但你可能要與不停止的話,試圖比較性能。

編輯:

爲了支持我在評論中提到的內容。不必拿出自己停止詞,這裏的NLTK的英文停用詞,您可以添加或刪除根據任何你想要實現:

>>> import nltk 
>>> from nltk.corpus import stopwords 
>>> stopwords.words('english') 
['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', 
'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 
'himself', 'she', 'her', 'hers', 'herself', 'it', 'its', 'itself', 
'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 
'who', 'whom', 'this', 'that', 'these', 'those', 'am', 'is', 'are', 
'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 
'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 
'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 
'with', 'about', 'against', 'between', 'into', 'through', 'during', 
'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down', 
'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 
'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 
'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 
'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 
't', 'can', 'will', 'just', 'don', 'should', 'now'] 
+0

我認爲類似你的方式。謝謝。 實際上,維護一個停止詞列表是不可能的,我的問題。因爲在文檔中,看起來像停用詞的單詞可能會以比平常高的分佈發生。我也不想錯過這些不尋常的單詞,但要消除平常/正常分佈的單詞。 無論如何,我會試試看。 – Muatik

+0

stopword lists存在於許多軟件包中預製,你不必自己想出或維護任何東西:)只是爲了澄清,這不是我的方式 - tf-idf是一個在信息檢索等已知的統計措施。另一個除了答案中的鏈接:http://nlp.stanford.edu/IR-book/html/htmledition/tf-idf-weighting-1.html – arturomp

1

看看Latent Dirichlet Allocation (LDA)。它是一種無監督算法,將「主題」視爲術語分佈,將文檔視爲主題分佈。它的源代碼廣泛用於多種語言(參見下面的一些示例庫)。

爲了消除停用詞,你可以簡單地找到一個停用詞列表在網上或通過您所選擇的語言下支持的包。通常這個選項被內置到文本挖掘或NLP包中。例子: