-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathemotion_confidence.py
More file actions
42 lines (28 loc) · 1018 Bytes
/
emotion_confidence.py
File metadata and controls
42 lines (28 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from prediction import tot_emotion
total_score_sum = 0
total_calls = 0
def calculate_emotion_score():
global total_score_sum, total_calls
emotion_data_list = tot_emotion()
if not emotion_data_list:
print("No emotion data available yet.")
return None
emotion_percentages = emotion_data_list[-1]
emotion_weights = {
"Happy": 40,
"Neutral": 35,
"Surprise": 15,
"Sad": 8,
"Fear": 5,
"Angry": 3,
"Disgust": 2
}
weighted_score = sum(emotion_percentages.get(emotion, 0) * weight for emotion, weight in emotion_weights.items())
max_possible_weight = sum(emotion_weights.values())
final_score = (weighted_score / (max_possible_weight * 100)) * 100
total_score_sum += final_score
total_calls += 1
average_score = total_score_sum / total_calls
print(f"Current Score: {round(final_score, 2)}")
print(f"Average Emotion Score: {round(average_score, 2)}")
return round(average_score, 2)