Commit
•
ab8868f
1
Parent(s):
5368a96
feature: create a tab for each subcategory of indicators
Browse files
app.py
CHANGED
@@ -5,14 +5,30 @@ import pandas as pd
|
|
5 |
def calculate_percentage(*answers):
|
6 |
yes_count = sum(answers)
|
7 |
percentage = yes_count / len(answers) * 100
|
8 |
-
return f"{percentage}%
|
9 |
|
10 |
|
11 |
df = pd.read_csv("fmti_indicators.csv")
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
5 |
def calculate_percentage(*answers):
|
6 |
yes_count = sum(answers)
|
7 |
percentage = yes_count / len(answers) * 100
|
8 |
+
return f"{percentage}%"
|
9 |
|
10 |
|
11 |
df = pd.read_csv("fmti_indicators.csv")
|
12 |
+
grouped = df.groupby(["Category", "Subcategory"])
|
13 |
|
14 |
+
interfaces = []
|
15 |
+
tab_names = []
|
16 |
+
for (category, subcategory), group in grouped:
|
17 |
+
questions = group["Definition"].tolist()
|
18 |
+
inputs = [gr.Checkbox(label=question) for question in questions]
|
19 |
+
output = gr.Textbox()
|
20 |
+
iface = gr.Interface(
|
21 |
+
fn=calculate_percentage,
|
22 |
+
inputs=inputs,
|
23 |
+
outputs=output,
|
24 |
+
title=f"{category} - {subcategory}",
|
25 |
+
)
|
26 |
+
interfaces.append(iface)
|
27 |
+
tab_names.append(subcategory)
|
28 |
|
29 |
+
tabbed_interface = gr.TabbedInterface(
|
30 |
+
interface_list=interfaces,
|
31 |
+
tab_names=tab_names,
|
32 |
+
title="The Foundation Model Transparency Index",
|
33 |
+
)
|
34 |
+
tabbed_interface.launch()
|