Spaces:
Runtime error
Runtime error
Update visualization.py
Browse files- visualization.py +15 -17
visualization.py
CHANGED
@@ -15,45 +15,45 @@ def create_charts(results):
|
|
15 |
# Attachment Styles
|
16 |
attachment_data = data['attachments']
|
17 |
labels = ['Secured', 'Anxious-Preoccupied', 'Dismissive-Avoidant', 'Fearful-Avoidant']
|
18 |
-
values = [attachment_data.secured, attachment_data.anxious_preoccupied,
|
19 |
-
attachment_data.dismissive_avoidant, attachment_data.fearful_avoidant]
|
20 |
|
21 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'orange', 'green', 'red'])])
|
22 |
fig.update_layout(title=f'{speaker_id}: Attachment Styles', yaxis_range=[0, 1])
|
23 |
charts[speaker_id]['attachment'] = fig
|
24 |
-
explanations[speaker_id]['attachment'] = attachment_data.explanation
|
25 |
|
26 |
# Big Five Traits
|
27 |
bigfive_data = data['bigfive']
|
28 |
labels = ['Extraversion', 'Agreeableness', 'Conscientiousness', 'Neuroticism', 'Openness']
|
29 |
-
values = [bigfive_data.extraversion, bigfive_data.agreeableness,
|
30 |
-
bigfive_data.conscientiousness, bigfive_data.neuroticism, bigfive_data.openness]
|
31 |
|
32 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'green', 'red', 'purple', 'orange'])])
|
33 |
fig.update_layout(title=f'{speaker_id}: Big Five Traits', yaxis_range=[0, 10])
|
34 |
charts[speaker_id]['bigfive'] = fig
|
35 |
-
explanations[speaker_id]['bigfive'] = bigfive_data.explanation
|
36 |
|
37 |
# Personality Disorders
|
38 |
personality_data = data['personalities']
|
39 |
labels = ['Depressed', 'Paranoid', 'Schizoid-Schizotypal', 'Antisocial-Psychopathic',
|
40 |
'Borderline-Dysregulated', 'Narcissistic', 'Anxious-Avoidant', 'Dependent-Victimized', 'Obsessional']
|
41 |
-
values = [personality_data.depressed, personality_data.paranoid,
|
42 |
-
personality_data.schizoid_schizotypal, personality_data.antisocial_psychopathic,
|
43 |
-
personality_data.borderline_dysregulated, personality_data.narcissistic,
|
44 |
-
personality_data.anxious_avoidant, personality_data.dependent_victimized,
|
45 |
-
personality_data.obsessional]
|
46 |
|
47 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['black', 'orange', 'gray', 'green', 'brown', 'purple', 'red', 'cyan', 'magenta'])])
|
48 |
fig.update_layout(title=f'{speaker_id}: Personality Disorders', yaxis_range=[0, 5])
|
49 |
charts[speaker_id]['personality'] = fig
|
50 |
-
explanations[speaker_id]['personality'] = personality_data.explanation
|
51 |
|
52 |
# Attachment Dimensions (Radar Chart)
|
53 |
dimensions_data = data['attachments']
|
54 |
labels = ['Self', 'Others', 'Anxiety', 'Avoidance']
|
55 |
-
values = [dimensions_data.self_model, dimensions_data.others_model,
|
56 |
-
dimensions_data.anxiety, dimensions_data.avoidance]
|
57 |
|
58 |
fig = go.Figure(data=go.Scatterpolar(
|
59 |
r=values,
|
@@ -71,6 +71,4 @@ def create_charts(results):
|
|
71 |
)
|
72 |
charts[speaker_id]['dimensions'] = fig
|
73 |
|
74 |
-
|
75 |
-
return charts, explanations, general_impressions
|
76 |
-
|
|
|
15 |
# Attachment Styles
|
16 |
attachment_data = data['attachments']
|
17 |
labels = ['Secured', 'Anxious-Preoccupied', 'Dismissive-Avoidant', 'Fearful-Avoidant']
|
18 |
+
values = [attachment_data.get('secured', 0), attachment_data.get('anxious_preoccupied', 0),
|
19 |
+
attachment_data.get('dismissive_avoidant', 0), attachment_data.get('fearful_avoidant', 0)]
|
20 |
|
21 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'orange', 'green', 'red'])])
|
22 |
fig.update_layout(title=f'{speaker_id}: Attachment Styles', yaxis_range=[0, 1])
|
23 |
charts[speaker_id]['attachment'] = fig
|
24 |
+
explanations[speaker_id]['attachment'] = attachment_data.get('explanation', "No explanation provided")
|
25 |
|
26 |
# Big Five Traits
|
27 |
bigfive_data = data['bigfive']
|
28 |
labels = ['Extraversion', 'Agreeableness', 'Conscientiousness', 'Neuroticism', 'Openness']
|
29 |
+
values = [bigfive_data.get('extraversion', 0), bigfive_data.get('agreeableness', 0),
|
30 |
+
bigfive_data.get('conscientiousness', 0), bigfive_data.get('neuroticism', 0), bigfive_data.get('openness', 0)]
|
31 |
|
32 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['blue', 'green', 'red', 'purple', 'orange'])])
|
33 |
fig.update_layout(title=f'{speaker_id}: Big Five Traits', yaxis_range=[0, 10])
|
34 |
charts[speaker_id]['bigfive'] = fig
|
35 |
+
explanations[speaker_id]['bigfive'] = bigfive_data.get('explanation', "No explanation provided")
|
36 |
|
37 |
# Personality Disorders
|
38 |
personality_data = data['personalities']
|
39 |
labels = ['Depressed', 'Paranoid', 'Schizoid-Schizotypal', 'Antisocial-Psychopathic',
|
40 |
'Borderline-Dysregulated', 'Narcissistic', 'Anxious-Avoidant', 'Dependent-Victimized', 'Obsessional']
|
41 |
+
values = [personality_data.get('depressed', 0), personality_data.get('paranoid', 0),
|
42 |
+
personality_data.get('schizoid_schizotypal', 0), personality_data.get('antisocial_psychopathic', 0),
|
43 |
+
personality_data.get('borderline_dysregulated', 0), personality_data.get('narcissistic', 0),
|
44 |
+
personality_data.get('anxious_avoidant', 0), personality_data.get('dependent_victimized', 0),
|
45 |
+
personality_data.get('obsessional', 0)]
|
46 |
|
47 |
fig = go.Figure(data=[go.Bar(x=labels, y=values, marker_color=['black', 'orange', 'gray', 'green', 'brown', 'purple', 'red', 'cyan', 'magenta'])])
|
48 |
fig.update_layout(title=f'{speaker_id}: Personality Disorders', yaxis_range=[0, 5])
|
49 |
charts[speaker_id]['personality'] = fig
|
50 |
+
explanations[speaker_id]['personality'] = personality_data.get('explanation', "No explanation provided")
|
51 |
|
52 |
# Attachment Dimensions (Radar Chart)
|
53 |
dimensions_data = data['attachments']
|
54 |
labels = ['Self', 'Others', 'Anxiety', 'Avoidance']
|
55 |
+
values = [dimensions_data.get('self_model', 0), dimensions_data.get('others_model', 0),
|
56 |
+
dimensions_data.get('anxiety', 0), dimensions_data.get('avoidance', 0)]
|
57 |
|
58 |
fig = go.Figure(data=go.Scatterpolar(
|
59 |
r=values,
|
|
|
71 |
)
|
72 |
charts[speaker_id]['dimensions'] = fig
|
73 |
|
74 |
+
return charts, explanations, general_impressions
|
|
|
|