evijit HF staff commited on
Commit
e8bb780
1 Parent(s): cd40158

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -23
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(selected_models, selected_categories):
490
- if not selected_models:
491
- fig = px.bar(title='Please select at least one model for comparison')
492
- fig.update_layout(showlegend=True) # Ensure legend remains visible
 
 
 
 
 
493
  return fig
494
 
495
  # Sort categories before processing
496
  selected_categories = sort_categories(selected_categories)
497
 
498
  data = []
499
- for model in selected_models:
500
  for category in selected_categories:
501
- if category in models[model]['scores']:
502
- total_score = 0
503
- total_questions = 0
504
 
505
- for section in models[model]['scores'][category].values():
506
  if section['status'] != 'N/A':
507
  questions = section.get('questions', {})
508
- total_score += sum(1 for q in questions.values() if q)
509
- total_questions += len(questions)
510
 
511
- score_percentage = (total_score / total_questions * 100) if total_questions > 0 else 0
512
- data.append({
513
- 'AI System': model,
514
- 'Category': category,
515
- 'Completion Rate': score_percentage
516
- })
 
517
 
518
  df = pd.DataFrame(data)
 
519
  if df.empty:
520
- fig = px.bar(title='No data available for the selected models and categories')
521
  else:
522
- fig = px.bar(df, x='AI System', y='Completion Rate', color='Category',
523
- title='AI System Evaluation Completion Rates by Category',
524
- labels={'Completion Rate': 'Completion Rate (%)'},
525
- category_orders={"Category": selected_categories})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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):