-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadarChart.py
73 lines (56 loc) · 1.96 KB
/
RadarChart.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import plotly.graph_objects as go
from AHPModel.AHPModel import ahp_model_weights
from ModelScoring import model_scoring
def radar_chart(user_scores, version=1):
if version==1:
labels = [label.replace('_', ' ').title() for label in user_scores.keys()]
values = list(user_scores.values())
layout = go.Layout(
polar=dict(
radialaxis=dict(
visible=False,
range=[0, 5] # Set the range according to your data values
)
)
)
fig = go.Figure(data=go.Scatterpolar(
r=values,
theta=labels,
fill='toself',
name='Your Score',
fillcolor='rgba(204, 161, 163, 0.7)',
line=dict(color='rgba(204, 161, 163, 1.0)')
))
fig.update_layout(layout)
if version==2:
model_weights = ahp_model_weights()
weighted_user_scores = model_scoring(user_scores, output='user_scores_weighted')
labels = [label.replace('_', ' ').title() for label in weighted_user_scores.keys()]
values_user = list(weighted_user_scores.values())
values_best = list(model_weights.values())
layout = go.Layout(
polar=dict(
radialaxis=dict(
visible=False,
range=[0, max(values_best)]
)
)
)
fig = go.Figure()
fig.add_trace(go.Scatterpolar(
r=values_user,
theta=labels,
fill='toself',
name='Your Score',
line=dict(color='red')
))
fig.add_trace(go.Scatterpolar(
r=values_best,
theta=labels,
fill='toself',
name='Target Score',
fillcolor='rgba(204, 161, 163, 0.7)',
line=dict(color='rgba(204, 161, 163, 1.0)')
))
fig.update_layout(layout)
return fig