feat: Emotion Intensity Metrics (Valence, Arousal, Diversity Index)#12
Open
cc-fuyu wants to merge 1 commit intoruxailab:mainfrom
Open
feat: Emotion Intensity Metrics (Valence, Arousal, Diversity Index)#12cc-fuyu wants to merge 1 commit intoruxailab:mainfrom
cc-fuyu wants to merge 1 commit intoruxailab:mainfrom
Conversation
Introduce a metrics module that computes derived intensity metrics from raw emotion percentage data, enabling richer quantitative analysis of user emotional responses. Key additions: - services/metrics/emotion_intensity.py: Core module implementing valence score, arousal score, Shannon entropy diversity index, dominance ratio, and human-readable interpretation - routes/video_routes.py: New POST /process_video_metrics endpoint returning both raw emotions and computed intensity metrics - tests/test_emotion_intensity.py: 20 unit tests covering all metric computations and edge cases Metrics computed: - valence_score [-1, +1]: weighted positivity/negativity - arousal_score [0, 1]: emotional activation level - diversity_index [0, 1]: Shannon entropy-based emotion spread - dominant_emotion & dominance_ratio: top emotion strength - interpretation: brief human-readable explanation This addresses the 'Confidence and Intensity Metrics' key feature of the GSoC 'Sentiment and Emotion Output Standardization' project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces emotion intensity metrics that compute derived quantitative indicators from raw emotion percentages. It directly addresses the "Confidence and Intensity Metrics" key feature of the GSoC 2026 project "Sentiment and Emotion Output Standardization for Usability Reports".
Problem
The current API returns only flat emotion percentages. While useful, they lack higher-level quantitative indicators that UX researchers need for comparative analysis across sessions, such as "Was this session more emotionally positive than the last?" or "How diverse were the user's emotions?"
Changes
New Module:
services/metrics/emotion_intensity.pyA pure-Python module (only uses
mathfrom stdlib) that computes:valence_scorearousal_scorediversity_indexdominant_emotiondominant_percentagedominance_ratiointerpretationPsychological Basis
The valence and arousal weights are based on the circumplex model of affect (Russell, 1980):
New Endpoint:
POST /process_video_metricsReturns both raw emotion percentages and computed intensity metrics.
Example Response
{ "emotions": {"Happy": 60.0, "Neutral": 15.0, "Surprised": 10.0, ...}, "intensity_metrics": { "valence_score": 0.4825, "arousal_score": 0.5830, "diversity_index": 0.7123, "dominant_emotion": "Happy", "dominant_percentage": 60.0, "dominance_ratio": 4.0, "interpretation": "The emotional response is predominantly positive. Emotional activation was moderate. There was moderate emotional diversity across the session." } }Unit Tests:
tests/test_emotion_intensity.py20 tests covering:
All tests pass:
20 passed in 0.05sBackward Compatibility
The original
/process_videoendpoint is not modified. The new/process_video_metricsendpoint is purely additive.