コミュニティの感情と有害性に関する質問

Community Sentiment および Toxicity モジュールの分類結果データベースを表示する方法については、Data Explorer プラグインと classification_results テーブルを使用することで可能です。

これは、AI プラグインがサイトでどのように機能し、投稿を分類しているかを確認するのに役立ちます。

AI Sentiment

SELECT target_id as post_id,
model_used,
classification->'negative' as negative,
classification->'neutral' as neutral,
classification->'positive' as positive
from classification_results
WHERE model_used = 'sentiment'
order by id desc

AI Emotion:

SELECT target_id as post_id,
model_used,
classification->'neutral' as neutral,
classification->'sadness' as sadness,
classification->'surprise' as surprise,
classification->'fear' as fear,
classification->'anger' as anger,
classification->'joy' as joy,
classification->'disgust' as disgust
from classification_results
WHERE model_used = 'emotion'
order by id desc

AI Toxicity:

SELECT target_id as post_id,
classification->'toxicity' as toxicity,
classification->'severe_toxicity' as severe_toxicity,
classification->'obscene' as obscene,
classification->'identity_attack' as identity_attack,
classification->'insult' as insult,
classification->'threat' as threat,
classification->'sexual_explicit' as sexual_explicit
From classification_results
WHERE classification_type = 'toxicity'
order by id desc

「いいね!」 8

特定の投稿スレッドからの投稿を取得するために、このクエリにフィルターを追加する方法はありますか? 現在はコミュニティ全体から投稿を取得しているようですが、これは便利である反面、探している特定の投稿/スレッドを見つけるのが煩雑になるだけでなく、このクエリの行制限に達してしまう可能性があります。

「いいね!」 2

Hi @Samantha_O :wave:

これは特定のトピックに機能しますか?パラメータでトピックIDを指定する必要があります。

-- [params]
-- int :topic_id = 

SELECT cr.target_id as post_id,
cr.model_used,
cr.classification->'negative' as negative,
cr.classification->'neutral' as neutral,
cr.classification->'positive' as positive
FROM classification_results cr
JOIN posts p ON p.id = cr.target_id
WHERE cr.model_used = 'sentiment'
AND p.topic_id = :topic_id
ORDER BY cr.id DESC
「いいね!」 6

ああ、先を越されましたね。:slight_smile:

しかし、特定の投稿用のものも用意しました。無駄な返信だと感じないようにするためです。

-- [params]
-- topic_id :topic_id
-- int :post_number

SELECT
    cr.target_id as post_id,
    cr.model_used,
    cr.classification->'negative' as negative,
    cr.classification->'neutral' as neutral,
    cr.classification->'positive' as positive
FROM classification_results cr
  JOIN posts p ON p.id = cr.target_id
WHERE cr.model_used = 'sentiment'
  AND p.topic_id = :topic_id
  AND p.post_number = :post_number

topic_idpost_number はどちらも URL で見つけることができるため、非常にユーザーフレンドリーです。

Topic_id:

Post_number:

「いいね!」 5

これはカテゴリIDを対象とするべきだと思います。

-- [params]
-- int :category_id = 

SELECT cr.target_id as post_id,
cr.model_used,
cr.classification->'negative' as negative,
cr.classification->'neutral' as neutral,
cr.classification->'positive' as positive
FROM classification_results cr
JOIN posts p ON p.id = cr.target_id
JOIN topics t ON t.id = p.topic_id
WHERE cr.model_used = 'sentiment'
AND t.category_id = :category_id
ORDER BY cr.id DESC

「いいね!」 5

お二人ともありがとうございます! これらを実行しても、古いトピック/トピックIDが見つかりません。センチメント分析は新しい投稿でのみ行われるのでしょうか?

明確化のため編集済み

「いいね!」 2

@JammyDodger さんならもっとよくご存知だと思いますが、はい、センチメント分析は新しい投稿でも機能すると思います。古い投稿で使用するには、おそらくレールコマンドを使用してセンチメントモデルで処理し、classification_results テーブル(新しい投稿の分析結果が格納されている場所)に取り込む必要があると思います。

「いいね!」 3

有効にすると、新しい投稿で機能します。:+1: バックフィルオプションがあるかどうかはわかりません。

「いいね!」 4

今後は新しい投稿のみとします。データの報告を開始し、検証を行った後に、その情報のバックフィルを検討できます。

「いいね!」 6

どなたか(または他の優秀なクエリ担当者)に、これをもう少し微調整するのを手伝っていただけますか?日付のパラメータがあり、それらの日付が投稿日に対応するようにしたいです。最終的な目標は、ダッシュボードが将来的にそれを実行できるかどうかを確認しながら、時間の経過に伴う変更を確認できるようにすることです。:crossed_fingers:

Samantha様

もし開始日と終了日のパラメータを含めてクエリを絞り込みたい場合は、次のようなクエリを使用できます。

-- [params]
-- date :start_date = 2023-01-01
-- date :end_date = 2024-01-01

SELECT 
p.created_at,
cr.target_id as post_id,
cr.model_used,
cr.classification->'negative' as negative,
cr.classification->'neutral' as neutral,
cr.classification->'positive' as positive
FROM classification_results cr
JOIN posts p ON p.id = cr.target_id
WHERE cr.model_used = 'sentiment'
AND p.created_at BETWEEN :start_date AND :end_date
ORDER BY cr.id DESC

結果例:

created_at post model_used negative neutral positive
2023-11-08T21:21:23.913Z post_id sentiment 58 38 2

ここで追加された重要な部分は、postsテーブルとclassification_resultsテーブルを結合して、次を追加できるようにすることです。

AND p.created_at BETWEEN :start_date AND :end_date

WHEREステートメントに追加して、created_at日付で投稿をフィルタリングします。

emotionおよびtoxicityの分類クエリは類似しているため、これらのクエリも同様の追加で変更して、開始日と終了日のパラメータを含めることができます。:slightly_smiling_face:

「いいね!」 4
「いいね!」 4

こちらも追加します:

「いいね!」 2

このクエリ(センチメント設定はセットアップ済み)を使用してみましたが、結果が何も返ってきません。トラブルシューティングのために試すべきことはありますか?

Dashboard Report - Overall Sentiment および Dashboard Report - Post Emotion のガイドを更新しました。更新されたクエリで再度試していただけますか?

「いいね!」 3