私はPython 3の感情分析で手をかけていましたが、文書のベクトル化にbag-of-wordsモデルのTDF-IDFベクトル化を使用していました。Pythonでの文書のベクトル化表現
だから、それに精通している人にとっては、結果として得られる行列表現は疎であることは明らかです。
ここに私のコードのスニペットがあります。まず、文書。
tweets = [('Once you get inside you will be impressed with the place.',1),('I got home to see the driest damn wings ever!',0),('An extensive menu provides lots of options for breakfast.',1),('The flair bartenders are absolutely amazing!',1),('My first visit to Hiro was a delight!',1),('Poor service, the waiter made me feel like I was stupid every time he came to the table.',0),('Loved this place.',1),('This restaurant has great food',1),
('Honeslty it did not taste THAT fresh :(',0),('Would not go back.',0),
('I was shocked because no signs indicate cash only.',0),
('Waitress was a little slow in service.',0),
('did not like at all',0),('The food, amazing.',1),
('The burger is good beef, cooked just right.',1),
('They have horrible attitudes towards customers, and talk down to each one when customers do not enjoy their food.',0),
('The cocktails are all handmade and delicious.',1),('This restaurant has terrible food',0),
('Both of the egg rolls were fantastic.',1),('The WORST EXPERIENCE EVER.',0),
('My friend loved the salmon tartar.',1),('Which are small and not worth the price.',0),
('This is the place where I first had pho and it was amazing!!',1),
('Horrible - do not waste your time and money.',0),('Seriously flavorful delights, folks.',1),
('I loved the bacon wrapped dates.',1),('I dressed up to be treated so rudely!',0),
('We literally sat there for 20 minutes with no one asking to take our order.',0),
('you can watch them preparing the delicious food! :)',1),('In the summer, you can dine in a charming outdoor patio - so very delightful.',1)]
X_train, y_train = zip(*tweets)
そして、文書をベクトル化するための次のコード。
tfidfvec = TfidfVectorizer(lowercase=True)
vectorized = tfidfvec.fit_transform(X_train)
print(vectorized)
vectorized
を印刷すると、通常のマトリックスは出力されません。代わりに、これは:
私が間違っていない場合、これは疎なマトリックス表現でなければなりません。しかし、私はその形式と各用語の意味を理解することができません。
また、30件のドキュメントがあります。つまり、最初の列の0-29が説明されています。それがトレンドなら、2番目の列は単語のインデックスであり、最後の値はtf-idfですと推測していますか?私の質問を書いている間に私は打ちのめされましたが、間違っていれば私を正しく修正します。
この経験をお持ちの方は、私がそれをよりよく理解するのに役立つでしょうか?