1
私はsklearnとcountvectorizerを初めて使っています。データにない単語を持つCountvectorizer
私には奇妙な現象が起こっています。
なぜこのような場合は0がある
df[df['description'].str.contains('rentalcontact')]
rentalcontact単語返される行数が含まれている行を取得
from sklearn.feature_extraction.text import CountVectorizer
count_vect = CountVectorizer()
document_mtrx = count_vect.fit_transform(df['description'])
count_vect.vocabulary_
count_vect.vocabulary_
Out[28]:
{u'viewscity': 36216,
u'sizeexposed': 31584,
u'rentalcontact': 29104,
u'villagebldg': 36323,
ベクトラのカウントを初期化しますか?
この用語の発生回数は29104です。しかし、最後のコード行を実行したときには、1回の結果しか返しませんでした。私にも欠けているものがありますか? – aceminer
@aceminer、AFAIK '29104'はソートされたフィーチャリスト内の' rentcontact'のインデックスです。確認方法: 'print(vectorizer.get_feature_names()[29104])' – MaxU
用語の頻度はどのように取得できますか? – aceminer