Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -486,45 +486,67 @@ with gr.Column(visible=True) as leaderboard_tab:
|
|
| 486 |
datatype=["markdown", "markdown", "markdown"] + ["markdown"] * (len(category_choices)+1) # Support markdown in all columns
|
| 487 |
)
|
| 488 |
|
| 489 |
-
def create_category_chart(
|
| 490 |
-
if not
|
| 491 |
-
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
return fig
|
| 494 |
|
| 495 |
# Sort categories before processing
|
| 496 |
selected_categories = sort_categories(selected_categories)
|
| 497 |
|
| 498 |
data = []
|
| 499 |
-
for
|
| 500 |
for category in selected_categories:
|
| 501 |
-
if category in models[
|
| 502 |
-
|
| 503 |
-
|
| 504 |
|
| 505 |
-
for section in models[
|
| 506 |
if section['status'] != 'N/A':
|
| 507 |
questions = section.get('questions', {})
|
| 508 |
-
|
| 509 |
-
|
| 510 |
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
|
|
|
| 517 |
|
| 518 |
df = pd.DataFrame(data)
|
|
|
|
| 519 |
if df.empty:
|
| 520 |
-
fig = px.bar(title='No data available for the selected
|
| 521 |
else:
|
| 522 |
-
fig = px.bar(
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
-
fig.update_layout(showlegend=True) # Ensure legend remains visible
|
| 528 |
return fig
|
| 529 |
|
| 530 |
def update_detailed_scorecard(model, selected_categories):
|
|
|
|
| 486 |
datatype=["markdown", "markdown", "markdown"] + ["markdown"] * (len(category_choices)+1) # Support markdown in all columns
|
| 487 |
)
|
| 488 |
|
| 489 |
+
def create_category_chart(selected_systems, selected_categories):
|
| 490 |
+
if not selected_systems:
|
| 491 |
+
# Create an empty figure with a prompt message
|
| 492 |
+
df = pd.DataFrame({'AI System': [], 'Category': [], 'Evaluations Completed': []})
|
| 493 |
+
fig = px.bar(df,
|
| 494 |
+
x='AI System',
|
| 495 |
+
y='Evaluations Completed',
|
| 496 |
+
title='Please select at least one AI system for comparison')
|
| 497 |
+
fig.update_layout(showlegend=True)
|
| 498 |
return fig
|
| 499 |
|
| 500 |
# Sort categories before processing
|
| 501 |
selected_categories = sort_categories(selected_categories)
|
| 502 |
|
| 503 |
data = []
|
| 504 |
+
for system_name in selected_systems:
|
| 505 |
for category in selected_categories:
|
| 506 |
+
if category in models[system_name]['scores']:
|
| 507 |
+
completed = 0
|
| 508 |
+
total = 0
|
| 509 |
|
| 510 |
+
for section in models[system_name]['scores'][category].values():
|
| 511 |
if section['status'] != 'N/A':
|
| 512 |
questions = section.get('questions', {})
|
| 513 |
+
completed += sum(1 for q in questions.values() if q)
|
| 514 |
+
total += len(questions)
|
| 515 |
|
| 516 |
+
if total > 0: # Only add if there are evaluations to do
|
| 517 |
+
data.append({
|
| 518 |
+
'AI System': system_name,
|
| 519 |
+
'Category': category.split('.')[1].strip(),
|
| 520 |
+
'Evaluations Completed': completed,
|
| 521 |
+
'Total Evaluations': total
|
| 522 |
+
})
|
| 523 |
|
| 524 |
df = pd.DataFrame(data)
|
| 525 |
+
|
| 526 |
if df.empty:
|
| 527 |
+
fig = px.bar(title='No data available for the selected AI systems and categories')
|
| 528 |
else:
|
| 529 |
+
fig = px.bar(
|
| 530 |
+
df,
|
| 531 |
+
x='AI System',
|
| 532 |
+
y='Evaluations Completed',
|
| 533 |
+
color='Category',
|
| 534 |
+
title='Number of Evaluations Completed by Category',
|
| 535 |
+
labels={
|
| 536 |
+
'Evaluations Completed': 'Evaluations Completed',
|
| 537 |
+
'AI System': 'AI System Name',
|
| 538 |
+
'Category': 'Evaluation Category'
|
| 539 |
+
},
|
| 540 |
+
hover_data=['Total Evaluations']
|
| 541 |
+
)
|
| 542 |
+
|
| 543 |
+
fig.update_layout(
|
| 544 |
+
showlegend=True,
|
| 545 |
+
xaxis_title="AI System Name",
|
| 546 |
+
yaxis_title="Number of Evaluations Completed",
|
| 547 |
+
# hovermode='x unified'
|
| 548 |
+
)
|
| 549 |
|
|
|
|
| 550 |
return fig
|
| 551 |
|
| 552 |
def update_detailed_scorecard(model, selected_categories):
|