私はVader SentimentAnalyzerを使用して極性スコアを取得しています。以前はポジティブ/ネガティブ/ニュートラルの確率スコアを使用していましたが、-1(最もネガティブ)から1(最もポジティブ)までの範囲の「化合物」スコアが単一の尺度になりました。私はどのように "化合物"のスコアが計算されたのだろうか。それは[pos、neu、neg]ベクトルから計算されますか?Python NLTKでベーダーの化合物の極性スコアはどのように計算されますか?
答えて
VADERアルゴリズム出力感情https://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L441の4クラスに感情スコア:
neg
:負neu
:ニュートラルpos
:正compound
:化合物(すなわち、凝集スコア)
compound = normalize(sum_s)
normalize()
機能はhttps://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L107でそのような次のように定義されます:
def normalize(score, alpha=15):
"""
Normalize the score to be between -1 and 1 using an alpha that
approximates the max expected value
"""
norm_score = score/math.sqrt((score*score) + alpha)
return norm_score
だからハイパーパラメータがありますのコードを見てみましょう、化合物の最初のインスタンスは、それが計算https://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L421、ですalpha
。
sum_s
としては、それはhttps://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L413
score_valence()
関数に渡された感情の引数の合計であり、我々はこのsentiment
引数をトレースバックあれば、我々はhttps://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L217でpolarity_scores()
関数を呼び出すときに、それが計算されますことを参照してください。
def polarity_scores(self, text):
"""
Return a float for sentiment strength based on the input text.
Positive values are positive valence, negative value are negative
valence.
"""
sentitext = SentiText(text)
#text, words_and_emoticons, is_cap_diff = self.preprocess(text)
sentiments = []
words_and_emoticons = sentitext.words_and_emoticons
for item in words_and_emoticons:
valence = 0
i = words_and_emoticons.index(item)
if (i < len(words_and_emoticons) - 1 and item.lower() == "kind" and \
words_and_emoticons[i+1].lower() == "of") or \
item.lower() in BOOSTER_DICT:
sentiments.append(valence)
continue
sentiments = self.sentiment_valence(valence, sentitext, item, i, sentiments)
sentiments = self._but_check(words_and_emoticons, sentiments)
polarity_scores
機能を見てみると、何のことはやっていることは目を割り当てるためのルールベースのsentiment_valence()
機能付き全SentiText辞書とチェックを反復処理することです感情https://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L243に電子価のスコアは、セクション2.1.1を参照してくださいhttp://comp.social.gatech.edu/papers/icwsm14.vader.hutto.pdf
だから、化合物のスコアに戻って、我々はそれを参照してください。
compound
スコアは正規化されたsum_s
のスコアと- です
sum_s
は、いくつかのヒューリスティックと感情辞書(aka。)に基づいて計算された価数の合計です。感情強度)と - 正規化されたスコアは、正規化関数の分母を増加させるアルファパラメータとその平方で除算された単純に
sum_s
です。
[POS、NEU、NEG]ベクトルから計算されたということですか?
そうでもない=)
我々はscore_valence
機能https://github.com/nltk/nltk/blob/develop/nltk/sentiment/vader.py#L411を見てみるならば、我々は、POS、NEGとNEUスコアが計算_sift_sentiment_scores()
を使用して計算される前に、化合物のスコアはsum_s
で計算されていることを確認invidiual pos、negおよびneuのスコアは合計なしでsentiment_valence()
の生スコアを使用しています。
alpha=0
:
(拘束されないままにした場合)
私たちは、このalpha
mathemagicを見ている場合は、alpha
の値に応じて、正規の出力はかなり不安定であると思われます
alpha=15
:
alpha=50000
:
alpha=0.001
:
それは負だとき、それはファンキー取得:
alpha=-10
:
alpha=-1,000,000
:
alpha=-1,000,000,000
:https://github.com/nltk/nltk/blob/develop/:
非常に良い説明は、あなたがグラフとequatioでsqrtの部分を見逃しているようですns –
- 1. Elasticsearch関連性スコアはどのように計算されますか?
- 2. Jawbone Appでの食物スコアの計算
- 3. のpython NLTK計算
- 4. 内部結合後の属性の合計を計算するにはどうすればよいですか?
- 5. 3つの割合の比はどのように計算されますか?
- 6. 合計はどのように計算できますか? dataGridView列の値のうちどれですか?
- 7. Rのオブジェクトサイズはどのように計算されますか?
- 8. XGBoostパッケージの機能スコア(/重要度)はどのように計算されますか?
- 9. Java化合物利息計算
- 10. サロゲートペアはどのように計算されますか?
- 11. emはどのように計算されますか?
- 12. Netlab - エラーはどのように計算されますか?
- 13. カフカオフセット値はどのように計算されますか?
- 14. 階乗はどのように計算されますか?
- 15. UIScrollView - showsHorizontalScrollIndicatorはどのように計算されますか?
- 16. gitハッシュはどのように計算されますか?
- 17. CSSグラジエントパスはどのように計算されますか?
- 18. 結合された文字列のスコアの計算
- 19. 集計レポートで合計スループット値はどのように計算されますか?
- 20. iostatのutilがどのように計算されますか?
- 21. EJB3メソッドのハッシュはどこでどのように計算されますか?
- 22. 各生徒の合計スコアを計算して保存し、クラス全体の平均スコアを計算します。
- 23. センチメント(トリンカ)のセンチメント関数から返される平均極性スコアの計算についての明確化が必要
- 24. SAPUI5で開始日と終了日の合計日数はどのように計算されますか?
- 25. 計算nGramsはNLTK
- 26. ベースE91、どのように計算されますか?
- 27. 偽陽性と真陰性の合計がゼロの場合、偽陽性率(FPR)を計算するにはどうすればよいですか?
- 28. パンダ:過去数日間の変数のローリング合計はどのように計算されますか?
- 29. テーブルの総数-1と1の合計数はどのように計算されますか? (C++)
- 30. 並列化された計算のランタイムを最小化するにはどうすればよいですか?
コードがですnltk/sentiment/vader.py – alvas