問題タブ [latent-semantic-indexing]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
gensim - Which formula of tf-idf does the LSA model of gensim use?
There are many different ways in which tf and idf can be calculated. I want to know which formula is used by gensim in its LSA model. I have been going through its source code lsimodel.py
, but it is not obvious to me where the document-term matrix is created (probably because of memory optimizations).
In one LSA paper, I read that each cell of the document-term matrix is the log-frequency of that word in that document, divided by the entropy of that word:
However, this seems to be a very unusual formulation of tf-idf. A more familiar form of tf-idf is:
I also notice that there is a question on how the TfIdfModel
itself is implemented in gensim. However, I didn't see lsimodel.py
importing TfIdfModel
, and therefore can only assume that lsimodel.py
has its own implementation of tf-idf.
python - LSI トピックの一貫性の「良い」値とは?
私は gensim python ライブラリを使用して、小さなコーパス (毎回約 1500 のプレス記事) で作業しています。同じニュースに関連する記事のクラスターを作成することに興味があるとしましょう。
そのため、トークン化した記事のコーパスごとに、コロケーションを検出し、ステミングを行ってから、TFIDF モデルに渡した小さな辞書 (約 20,000 トークン) をフィードしました。
最後に、TFIDF コーパスを使用してコーパスの LSI モデルを構築し、gensim のドキュメント類似機能を利用して、非常に良い結果を得ることができました。
しかし、私は興味があり、LSI のコヒーレンス チェックを次のように行いました。
そして、私は常に 0.45 前後の値を取得しますが、これはかなり弱いように見えます。
それで、このコヒーレンス値をどのように解釈するのか疑問に思っていましたか? また、インデックス内のドキュメントとインデックス自体の類似性のみが必要な場合 (つまり、クエリはコーパスからの完全なドキュメントである場合)、この値は意味がありますか?
編集: Phrases クラスに入力する前に各ドキュメントを実際の文に分割する、バイグラム、トリグラムを生成する、またはアクセントを削除するなど、テキストの前処理のためにさまざまなことを試しましたが、場合によっては約 0.55 のコヒーレンス値を取得できたので、少なくとも生データを処理する最も効率的な方法を見つけるのに役立つと思います...
python - gensim LSI のドキュメントに起因するトピック スコアを取得するにはどうすればよいですか?
私はPythonとMLの初心者です。LDA の各ドキュメントに関連付けられたトピックを取得する方法に関する素敵なスクリプト ( https://www.machinelearningplus.com/nlp/topic-modeling-visualization-how-to-present-results-lda-models/ ) を見つけました。 LSIでも使えるように変更しました。元のコードは次のとおりです。
LSI に使用するために、次のように変更しました。
- これは正しい方法ですか?
- LSI は確率に基づいていないため、「Perc_Contrib」は 100% を超えています。この数字をどのように解釈すればよいでしょうか?
- 上記のスクリプトとは別に、LSI には get_document_topics がないため、どの関数を使用して最もスコアの高いトピックを表示できますか?