diff --git a/frontend/src/components/EmotionalStats.tsx b/frontend/src/components/EmotionalStats.tsx index 07b2eea..4da8259 100644 --- a/frontend/src/components/EmotionalStats.tsx +++ b/frontend/src/components/EmotionalStats.tsx @@ -9,6 +9,8 @@ type EmotionalStatsProps = { const EmotionalStats = ({contentData}: EmotionalStatsProps) => { const rows = contentData.average_emotion_by_topic ?? []; + const lowSampleThreshold = 20; + const stableSampleThreshold = 50; const emotionKeys = rows.length ? Object.keys(rows[0]).filter((key) => key.startsWith("emotion_")) : []; @@ -38,6 +40,18 @@ const EmotionalStats = ({contentData}: EmotionalStatsProps) => { return value.charAt(0).toUpperCase() + value.slice(1); }; + const sampleSizes = strongestPerTopic + .map((topic) => topic.count) + .filter((count) => Number.isFinite(count) && count > 0) + .sort((a, b) => a - b); + + const lowSampleTopics = strongestPerTopic.filter((topic) => topic.count < lowSampleThreshold).length; + const stableSampleTopics = strongestPerTopic.filter((topic) => topic.count >= stableSampleThreshold).length; + + const medianSampleSize = sampleSizes.length + ? sampleSizes[Math.floor(sampleSizes.length / 2)] + : 0; + if (!rows.length) { return (
@@ -51,7 +65,16 @@ const EmotionalStats = ({contentData}: EmotionalStatsProps) => {

Average Emotion by Topic

-

Mean emotion scores for each detected topic

+

Read confidence together with sample size. Topics with fewer than {lowSampleThreshold} events are usually noisy and less reliable.

+
+ Topics: {strongestPerTopic.length} + Median Sample: {medianSampleSize} events + Low Sample (<{lowSampleThreshold}): {lowSampleTopics} + Stable Sample ({stableSampleThreshold}+): {stableSampleTopics} +
+

+ Confidence reflects how strongly one emotion leads within a topic, not model accuracy. Use larger samples for stronger conclusions. +