Emoji-AI-Avatar / evaluation /emotion_statistics.py
Deminiko
Initial import: Emoji AI Avatar
25e624c
# -*- coding: utf-8 -*-
"""
Emotion Statistics - Complete overview of all emotions managed by the system
Shows:
- Total emotion count
- Emoji mapping
- Recognition accuracy from latest evaluation
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from avatar.sentiment_emoji_map import EmojiMapper
def get_emotion_stats():
"""Generate complete emotion statistics table"""
mapper = EmojiMapper()
all_emojis = mapper.get_all_emojis()
# Remove legacy/system mappings for counting
legacy_keys = ["very_negative", "negative", "slightly_negative",
"slightly_positive", "positive", "very_positive",
"default", "ready"]
emotion_emojis = {k: v for k, v in all_emojis.items() if k not in legacy_keys}
# Recognition accuracy from latest evaluation (Multi-Emotion V2)
# Data from evaluation/reports/comparison_multi-v2_2025-12-01_18-46-46.md
recognition_accuracy = {
# 100% accuracy
"excitement": 100.0, "thrill": 100.0, "delight": 100.0, "cheerfulness": 100.0,
"enthusiasm": 100.0, "calm": 100.0, "pleasure": 100.0, "love": 100.0,
"affection": 100.0, "tenderness": 100.0, "caring": 100.0, "compassion": 100.0,
"empathy": 100.0, "gratitude": 100.0, "wonder": 100.0, "awe": 100.0,
"amazement": 100.0, "surprise": 100.0, "thinking": 100.0, "sadness": 100.0,
"grief": 100.0, "disappointment": 100.0, "loneliness": 100.0, "hurt": 100.0,
"fear": 100.0, "terror": 100.0, "horror": 100.0, "dread": 100.0,
"anxiety": 100.0, "worry": 100.0, "nervousness": 100.0, "panic": 100.0,
"anger": 100.0, "fury": 100.0, "irritation": 100.0, "hostility": 100.0,
"disgust": 100.0, "contempt": 100.0, "disdain": 100.0, "shame": 100.0,
"embarrassment": 100.0, "guilt": 100.0, "regret": 100.0, "remorse": 100.0,
"tiredness": 100.0, "jealousy": 100.0, "sympathy": 100.0, "nostalgia": 100.0,
"pessimism": 100.0, "yearning": 100.0, "determination": 100.0,
"anticipation": 100.0, "trust": 100.0,
# 90%+
"happiness": 90.0, "silly": 87.5, "joy": 85.7, "pride": 85.7,
"uncertain": 85.7, "confused": 85.7, "playful": 85.7, "hope": 85.7,
# 80%+
"satisfaction": 83.3, "relaxed": 83.3, "relief": 83.3, "interest": 83.3,
"shock": 83.3, "annoyance": 83.3, "frustration": 83.3, "boredom": 83.3,
"optimism": 83.3, "elation": 80.0, "euphoria": 80.0, "serenity": 80.0,
"adoration": 80.0, "fascination": 80.0, "intrigue": 80.0, "astonishment": 80.0,
"puzzled": 80.0, "perplexed": 80.0, "bewildered": 80.0, "baffled": 80.0,
"sorrow": 80.0, "melancholy": 80.0, "despair": 80.0, "misery": 80.0,
"apprehension": 80.0, "rage": 80.0, "resentment": 80.0, "bitterness": 80.0,
"revulsion": 80.0, "scorn": 80.0, "humiliation": 80.0, "exhaustion": 80.0,
"fatigue": 80.0, "weariness": 80.0, "inspiration": 80.0, "sarcasm": 80.0,
# 70%+
"neutral": 76.9, "amusement": 72.7, "ecstasy": 71.4, "longing": 71.4,
# 60%+
"envy": 66.7, "mischievous": 66.7, "acceptance": 60.0,
# 50%+
"contentment": 57.1, "curiosity": 57.1, "confidence": 50.0,
}
# Categories
categories = {
"POSITIVE (High Arousal)": ["ecstasy", "joy", "happiness", "delight", "elation",
"euphoria", "excitement", "thrill", "enthusiasm", "cheerfulness"],
"POSITIVE (Medium Arousal)": ["contentment", "satisfaction", "pleasure", "relief",
"serenity", "calm", "relaxed", "pride", "confidence", "triumph"],
"LOVE & AFFECTION": ["love", "adoration", "affection", "tenderness", "caring",
"compassion", "empathy", "gratitude", "thankful"],
"INTEREST & CURIOSITY": ["curiosity", "interest", "fascination", "wonder", "awe",
"amazement", "intrigue"],
"SURPRISE": ["surprise", "astonishment", "shock", "startled"],
"NEUTRAL / THINKING": ["neutral", "thinking", "contemplative", "pensive", "reflective",
"uncertain", "ambivalent", "indifferent"],
"CONFUSION": ["confused", "confusion", "puzzled", "perplexed", "bewildered", "baffled"],
"SADNESS": ["sadness", "sorrow", "grief", "melancholy", "disappointment", "dejection",
"despair", "hopelessness", "loneliness", "hurt", "misery"],
"FEAR & ANXIETY": ["fear", "terror", "horror", "dread", "anxiety", "worry",
"nervousness", "apprehension", "panic"],
"ANGER & FRUSTRATION": ["anger", "rage", "fury", "irritation", "annoyance", "frustration",
"exasperation", "resentment", "hostility", "bitterness"],
"DISGUST & CONTEMPT": ["disgust", "revulsion", "contempt", "disdain", "loathing", "scorn"],
"SHAME & EMBARRASSMENT": ["shame", "embarrassment", "guilt", "regret", "remorse", "humiliation"],
"BOREDOM & TIREDNESS": ["boredom", "tiredness", "exhaustion", "fatigue", "weariness", "sleepy"],
"ENVY & JEALOUSY": ["envy", "jealousy"],
"PLAYFUL & SILLY": ["playful", "silly", "mischievous", "teasing", "sarcastic", "witty",
"amusement", "funny"],
"SPECIAL STATES": ["sympathy", "nostalgia", "hope", "optimism", "pessimism", "longing",
"yearning", "determination", "inspiration", "anticipation", "trust",
"acceptance", "sarcasm"],
}
return emotion_emojis, recognition_accuracy, categories
def print_emotion_table():
"""Print formatted emotion statistics table"""
emotion_emojis, recognition_accuracy, categories = get_emotion_stats()
print("=" * 80)
print("EMOJI AI AVATAR - EMOTION RECOGNITION STATISTICS")
print("=" * 80)
print()
print(f"๐Ÿ“Š Total Emotions Mapped: {len(emotion_emojis)}")
print(f"๐Ÿ“Š Emotions with Recognition Data: {len(recognition_accuracy)}")
print(f"๐Ÿ“Š Overall Recognition Accuracy: 89.0%")
print()
# Print by category
for category, emotions in categories.items():
print(f"\n{'โ”€' * 80}")
print(f"๐Ÿ“ {category}")
print(f"{'โ”€' * 80}")
print(f"{'Emotion':<20} {'Emoji':<6} {'Accuracy':<10} {'Status'}")
print(f"{'โ”€' * 20} {'โ”€' * 5} {'โ”€' * 9} {'โ”€' * 10}")
for emotion in emotions:
emoji = emotion_emojis.get(emotion, "โ“")
accuracy = recognition_accuracy.get(emotion, None)
if accuracy is not None:
if accuracy >= 80:
status = "โœ… PASS"
elif accuracy >= 50:
status = "โš ๏ธ OK"
else:
status = "โŒ FAIL"
acc_str = f"{accuracy:.1f}%"
else:
status = "๐Ÿ”น N/T" # Not tested
acc_str = "N/A"
print(f"{emotion:<20} {emoji:<6} {acc_str:<10} {status}")
# Summary statistics
print()
print("=" * 80)
print("SUMMARY STATISTICS")
print("=" * 80)
tested = [acc for acc in recognition_accuracy.values()]
perfect = sum(1 for acc in tested if acc == 100.0)
high = sum(1 for acc in tested if 80.0 <= acc < 100.0)
medium = sum(1 for acc in tested if 50.0 <= acc < 80.0)
low = sum(1 for acc in tested if acc < 50.0)
print(f"โœ… 100% Accuracy: {perfect} emotions")
print(f"โœ… 80-99% Accuracy: {high} emotions")
print(f"โš ๏ธ 50-79% Accuracy: {medium} emotions")
print(f"โŒ <50% Accuracy: {low} emotions")
print()
print(f"Average Accuracy: {sum(tested)/len(tested):.1f}%")
print()
def generate_markdown_table():
"""Generate markdown table for documentation"""
emotion_emojis, recognition_accuracy, categories = get_emotion_stats()
lines = [
"# Emoji AI Avatar - Complete Emotion Table",
"",
f"**Total Emotions:** {len(emotion_emojis)}",
f"**Overall Accuracy:** 89.0%",
f"**Last Updated:** 2025-12-01",
"",
"## Recognition Accuracy by Category",
"",
]
for category, emotions in categories.items():
lines.append(f"### {category}")
lines.append("")
lines.append("| Emotion | Emoji | Accuracy | Status |")
lines.append("|---------|-------|----------|--------|")
for emotion in emotions:
emoji = emotion_emojis.get(emotion, "โ“")
accuracy = recognition_accuracy.get(emotion, None)
if accuracy is not None:
if accuracy >= 80:
status = "โœ… PASS"
elif accuracy >= 50:
status = "โš ๏ธ OK"
else:
status = "โŒ FAIL"
acc_str = f"{accuracy:.1f}%"
else:
status = "๐Ÿ”น N/T"
acc_str = "N/A"
lines.append(f"| {emotion} | {emoji} | {acc_str} | {status} |")
lines.append("")
# Add summary
tested = list(recognition_accuracy.values())
perfect = sum(1 for acc in tested if acc == 100.0)
high = sum(1 for acc in tested if 80.0 <= acc < 100.0)
medium = sum(1 for acc in tested if 50.0 <= acc < 80.0)
low = sum(1 for acc in tested if acc < 50.0)
lines.extend([
"## Summary",
"",
"| Accuracy Range | Count |",
"|----------------|-------|",
f"| 100% (Perfect) | {perfect} |",
f"| 80-99% (High) | {high} |",
f"| 50-79% (Medium) | {medium} |",
f"| <50% (Low) | {low} |",
"",
f"**Average Accuracy:** {sum(tested)/len(tested):.1f}%",
"",
])
return "\n".join(lines)
if __name__ == "__main__":
print_emotion_table()
# Also save markdown version
md_content = generate_markdown_table()
output_path = os.path.join(os.path.dirname(__file__), "reports", "emotion_statistics.md")
with open(output_path, "w", encoding="utf-8") as f:
f.write(md_content)
print(f"\n๐Ÿ“„ Markdown table saved to: {output_path}")