Pratik Bhavsar commited on
Commit
6ed7668
·
1 Parent(s): a5bf7de

initial leaderboard

Browse files
Files changed (2) hide show
  1. app.py +66 -16
  2. requirements.txt +2 -1
app.py CHANGED
@@ -2,31 +2,81 @@ import gradio as gr
2
  import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import numpy as np
 
5
 
6
  df = pd.read_csv("results.csv").dropna()
7
  dataset_columns = df.columns[7:].tolist()
8
 
9
 
10
- def create_radar_plot(df, model_name):
11
- model_data = df[df["Model"] == model_name].iloc[0]
12
- metrics = df.columns[7:].tolist()
13
 
14
- values = [model_data[m] for m in metrics]
15
- angles = np.linspace(0, 2 * np.pi, len(metrics), endpoint=False)
16
 
17
- # Close the plot by appending values to match angles length
18
- angles = np.concatenate((angles, [angles[0]])) # Add first angle again
19
- values = np.concatenate((values, [values[0]])) # Add first value again
20
 
21
- fig, ax = plt.subplots(figsize=(10, 10), subplot_kw=dict(projection="polar"))
22
- ax.plot(angles, values)
23
- ax.fill(angles, values, alpha=0.25)
24
- ax.set_xticks(angles[:-1]) # Exclude the last duplicate angle
25
- ax.set_xticklabels(metrics, size=8)
26
- ax.set_title(model_name)
27
 
28
- return fig
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  def model_info_tab(model_name=None):
32
  if model_name is None:
@@ -202,7 +252,7 @@ with gr.Blocks() as app:
202
  value=df.sort_values("Model Avg", ascending=False).iloc[0][
203
  "Model"
204
  ],
205
- label="Select Model",
206
  )
207
  with gr.Column(scale=4):
208
  model_info = gr.HTML()
 
2
  import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import numpy as np
5
+ import plotly.graph_objects as go
6
 
7
  df = pd.read_csv("results.csv").dropna()
8
  dataset_columns = df.columns[7:].tolist()
9
 
10
 
11
+ # def create_radar_plot(df, model_name):
12
+ # model_data = df[df["Model"] == model_name].iloc[0]
13
+ # datasets = df.columns[7:].tolist()
14
 
15
+ # values = [model_data[m] for m in datasets]
16
+ # angles = np.linspace(0, 2 * np.pi, len(datasets), endpoint=False)
17
 
18
+ # # Close the plot by appending values to match angles length
19
+ # angles = np.concatenate((angles, [angles[0]])) # Add first angle again
20
+ # values = np.concatenate((values, [values[0]])) # Add first value again
21
 
22
+ # fig, ax = plt.subplots(figsize=(10, 10), subplot_kw=dict(projection="polar"))
23
+ # ax.plot(angles, values)
24
+ # ax.fill(angles, values, alpha=0.25)
25
+ # ax.set_xticks(angles[:-1]) # Exclude the last duplicate angle
26
+ # ax.set_xticklabels(datasets, size=8, fontweight="bold")
27
+ # ax.set_title(model_name, pad=5, y=1.05, fontsize=12, fontweight="bold")
28
 
29
+ # return fig
30
 
31
+ def create_radar_plot(df, model_name):
32
+ model_data = df[df["Model"] == model_name].iloc[0]
33
+ datasets = df.columns[7:].tolist()
34
+ values = [model_data[m] for m in datasets]
35
+ values.append(values[0])
36
+ datasets.append(datasets[0])
37
+
38
+ fig = go.Figure(
39
+ data=go.Scatterpolar(
40
+ r=values,
41
+ theta=datasets,
42
+ fill="toself",
43
+ fillcolor="rgba(99, 102, 241, 0.3)",
44
+ line=dict(color="#4F46E5", width=2),
45
+ name=model_name,
46
+ text=[f"{val:.3f}" for val in values],
47
+ textposition="middle right",
48
+ mode="lines+markers+text",
49
+ )
50
+ )
51
+
52
+ fig.update_layout(
53
+ polar=dict(
54
+ radialaxis=dict(
55
+ visible=True,
56
+ range=[0, 1],
57
+ showline=False,
58
+ tickfont=dict(size=12),
59
+ ),
60
+ angularaxis=dict(
61
+ tickfont=dict(size=13, family="Arial"),
62
+ rotation=90,
63
+ direction="clockwise",
64
+ ),
65
+ ),
66
+ showlegend=False,
67
+ title=dict(
68
+ text=model_name,
69
+ x=0.5,
70
+ y=0.95,
71
+ font=dict(size=24, family="Arial", color="#1F2937"),
72
+ ),
73
+ paper_bgcolor="rgba(0,0,0,0)",
74
+ plot_bgcolor="rgba(0,0,0,0)",
75
+ height=800,
76
+ width=1000,
77
+ )
78
+
79
+ return fig
80
 
81
  def model_info_tab(model_name=None):
82
  if model_name is None:
 
252
  value=df.sort_values("Model Avg", ascending=False).iloc[0][
253
  "Model"
254
  ],
255
+ label="Model",
256
  )
257
  with gr.Column(scale=4):
258
  model_info = gr.HTML()
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  pandas
2
- matplotlib
 
 
1
  pandas
2
+ matplotlib
3
+ plotly