0
我正在嘗試使用TFIDF從文本文章的標題中獲取功能。我做的是以下情況:SciKit-Learn:TfidfVectorizer故障
from sklearn.feature_extraction.text import TfidfVectorizer
corpus_title = result_df['_title'].tolist()
tfidf_transformer_title = TfidfVectorizer(min_df = 1, ngram_range = (1,1), use_idf = True, stop_words='english')
tfidf_df_title = tfidf_transformer_title.fit_transform(corpus_title)
tfidf_df_title
不過,我在這條線得到一個錯誤:
----> 4 tfidf_df_title = tfidf_transformer_title.fit_transform(corpus_title)
的錯誤是:
205
206 if self.lowercase:
--> 207 return lambda x: strip_accents(x.lower())
208 else:
209 return strip_accents
AttributeError: 'NoneType' object has no attribute 'lower'
我不知道它是如何可能得到這個錯誤。我檢查了文檔,它看上去像TfidfVectorizer
使用UTF-8作爲其默認編碼。
任何想法如何解決?
謝謝!
你的陰莖似乎有一些有問題的項目。 –
@cᴏʟᴅsᴘᴇᴇᴅ是否有跳過這些條目的方法? – bclayman
不熟悉熊貓,但您可以仔細查看導致問題的數據,然後使用布爾索引將其過濾掉。 –