第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何用analyzer ='char'計(jì)算Tf-Idf值?

如何用analyzer ='char'計(jì)算Tf-Idf值?

縹緲止盈 2021-09-25 10:08:29
我在理解我們?nèi)绾卧谝韵鲁绦蛑蝎@得 Tf-Idf 時(shí)遇到問題:我曾嘗試使用網(wǎng)站上給出的概念計(jì)算a文檔 2 ( 'And_this_is_the_third_one.') 中的值,但使用上述概念我的 'a' 值是1/26*日志(4/1)(('a' 字符出現(xiàn)的次數(shù))/(給定文檔中的字符數(shù))*log(# Docs/ # 出現(xiàn)給定字符的文檔))= 0.023156但是輸出返回為 0.2203,如輸出所示。from sklearn.feature_extraction.text import TfidfVectorizercorpus = ['This_is_the_first_document.', 'This_document_is_the_second_document.', 'And_this_is_the_third_one.', 'Is_this_the_first_document?', ]vectorizer = TfidfVectorizer(min_df=0.0, analyzer="char")X = vectorizer.fit_transform(corpus)print(vectorizer.get_feature_names())print(vectorizer.vocabulary_)m = X.todense()print(m)使用上面解釋的概念,我預(yù)計(jì)輸出為 0.023156。輸出是:['.', '?', '_', 'a', 'c', 'd', 'e', 'f', 'h', 'i', 'm', 'n', 'o', 'r', 's', 't', 'u']{'t': 15, 'h': 8, 'i': 9, 's': 14, '_': 2, 'e': 6, 'f': 7, 'r': 13, 'd': 5, 'o': 12, 'c': 4, 'u': 16, 'm': 10, 'n': 11, '.': 0, 'a': 3, '?': 1}[[0.14540332 0.         0.47550697 0.         0.14540332 0.11887674  0.23775349 0.17960203 0.23775349 0.35663023 0.14540332 0.11887674  0.11887674 0.14540332 0.35663023 0.47550697 0.14540332] [0.10814145 0.         0.44206359 0.         0.32442434 0.26523816  0.35365088 0.         0.17682544 0.17682544 0.21628289 0.26523816  0.26523816 0.         0.26523816 0.35365088 0.21628289] [0.14061506 0.         0.57481012 0.22030066 0.         0.22992405  0.22992405 0.         0.34488607 0.34488607 0.         0.22992405  0.11496202 0.14061506 0.22992405 0.34488607 0.        ] [0.         0.2243785  0.46836004 0.         0.14321789 0.11709001  0.23418002 0.17690259 0.23418002 0.35127003 0.14321789 0.11709001  0.11709001 0.14321789 0.35127003 0.46836004 0.14321789]]
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)