mariagrandury commited on
Commit
8a9ef5d
·
1 Parent(s): 8b57f56

add rules to calculate team scores

Browse files
calculate_personal_scores.py CHANGED
@@ -1,14 +1,11 @@
1
  import json
2
  import os
3
- import time
4
  from collections import defaultdict
5
  from functools import lru_cache
6
 
7
  import argilla as rg
8
- import gradio as gr
9
  import pandas as pd
10
  from dotenv import load_dotenv
11
- from fastapi import FastAPI
12
 
13
  load_dotenv()
14
 
@@ -361,4 +358,4 @@ def calculate_personal_scores():
361
 
362
 
363
  if __name__ == "__main__":
364
- calculate_scores()
 
1
  import json
2
  import os
 
3
  from collections import defaultdict
4
  from functools import lru_cache
5
 
6
  import argilla as rg
 
7
  import pandas as pd
8
  from dotenv import load_dotenv
 
9
 
10
  load_dotenv()
11
 
 
358
 
359
 
360
  if __name__ == "__main__":
361
+ calculate_personal_scores()
calculate_team_scores.py CHANGED
@@ -1,14 +1,7 @@
1
- import json
2
  import os
3
- import time
4
- from collections import defaultdict
5
- from functools import lru_cache
6
 
7
- import argilla as rg
8
- import gradio as gr
9
  import pandas as pd
10
  from dotenv import load_dotenv
11
- from fastapi import FastAPI
12
 
13
  from calculate_personal_scores import get_discord_username
14
 
@@ -31,6 +24,33 @@ TEAM_COLUMNS = {
31
  "email_5": "Email 5",
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  def get_team_leaderboard(personal_leaderboard_df):
36
  """Calculate team leaderboard based on personal scores."""
@@ -82,6 +102,17 @@ def get_team_leaderboard(personal_leaderboard_df):
82
  while len(discord_usernames) < 5:
83
  discord_usernames.append("")
84
 
 
 
 
 
 
 
 
 
 
 
 
85
  # Create team row
86
  team_row_data = {
87
  "team_name": team_name,
@@ -91,22 +122,22 @@ def get_team_leaderboard(personal_leaderboard_df):
91
  "discord_4": discord_usernames[3],
92
  "discord_5": discord_usernames[4],
93
  "total_arena": team_scores["arena"],
94
- "ptos_arena": 0, # Set to 0 for now as requested
95
  "total_blend_es": team_scores["blend_es"],
96
- "ptos_blend_es": 0, # Set to 0 for now as requested
97
  "total_estereotipos": team_scores["estereotipos"],
98
- "ptos_estereotipos": 0, # Set to 0 for now as requested
99
  "total_include": team_scores["include"],
100
- "ptos_include": 0, # Set to 0 for now as requested
101
- "ptos_total": 0, # Set to 0 for now as requested
102
  }
103
 
104
  team_leaderboard.append(team_row_data)
105
 
106
- # Create DataFrame and sort by total_arena
107
  if team_leaderboard:
108
  team_df = pd.DataFrame(team_leaderboard)
109
- team_df.sort_values("total_arena", ascending=False, inplace=True)
110
  return team_df
111
  else:
112
  return pd.DataFrame()
@@ -120,6 +151,8 @@ def calculate_team_scores():
120
  personal_leaderboard_df = pd.read_csv(LEADERBOARD_PERSONAL_CSV)
121
  team_leaderboard_df = get_team_leaderboard(personal_leaderboard_df)
122
  team_leaderboard_df.to_csv(LEADERBOARD_EQUIPOS_CSV, index=False, encoding="utf-8")
 
 
123
 
124
 
125
  if __name__ == "__main__":
 
 
1
  import os
 
 
 
2
 
 
 
3
  import pandas as pd
4
  from dotenv import load_dotenv
 
5
 
6
  from calculate_personal_scores import get_discord_username
7
 
 
24
  "email_5": "Email 5",
25
  }
26
 
27
+ # INCLUDE: Cada 100 preguntas validadas extraídas por equipo = 0.5 ptos (máx 1 pto)
28
+ # Estereotipos: Cada 10 estereotipos validados por equipo = 0.1 ptos (máx 1 pto)
29
+ # BLEND: Cada 50 preguntas por equipo = 0.5 ptos (máx 2 ptos)
30
+ # Arena: Cada 50 prompts por equipo = 0.5 ptos (máx 2 ptos)
31
+
32
+ POINTS = {
33
+ "INCLUDE": {"points": 0.5, "max_points": 1, "questions": 100},
34
+ "ESTEREOTIPOS": {"points": 0.1, "max_points": 1, "questions": 10},
35
+ "BLEND": {"points": 0.5, "max_points": 2, "questions": 50},
36
+ "ARENA": {"points": 0.5, "max_points": 2, "questions": 50},
37
+ }
38
+
39
+
40
+ def calculate_challenge_points(total_score, challenge_name):
41
+ """Calculate points for a specific challenge based on the POINTS rules."""
42
+ if challenge_name not in POINTS:
43
+ return 0
44
+
45
+ challenge_rules = POINTS[challenge_name]
46
+ points_per_unit = challenge_rules["points"]
47
+ max_points = challenge_rules["max_points"]
48
+ questions_per_unit = challenge_rules["questions"]
49
+
50
+ calculated_points = (total_score / questions_per_unit) * points_per_unit
51
+ final_points = min(calculated_points, max_points)
52
+ return round(final_points, 2)
53
+
54
 
55
  def get_team_leaderboard(personal_leaderboard_df):
56
  """Calculate team leaderboard based on personal scores."""
 
102
  while len(discord_usernames) < 5:
103
  discord_usernames.append("")
104
 
105
+ # Calculate points for each challenge
106
+ ptos_arena = calculate_challenge_points(team_scores["arena"], "ARENA")
107
+ ptos_blend_es = calculate_challenge_points(team_scores["blend_es"], "BLEND")
108
+ ptos_estereotipos = calculate_challenge_points(
109
+ team_scores["estereotipos"], "ESTEREOTIPOS"
110
+ )
111
+ ptos_include = calculate_challenge_points(team_scores["include"], "INCLUDE")
112
+
113
+ # Calculate total points
114
+ ptos_total = ptos_arena + ptos_blend_es + ptos_estereotipos + ptos_include
115
+
116
  # Create team row
117
  team_row_data = {
118
  "team_name": team_name,
 
122
  "discord_4": discord_usernames[3],
123
  "discord_5": discord_usernames[4],
124
  "total_arena": team_scores["arena"],
125
+ "ptos_arena": ptos_arena,
126
  "total_blend_es": team_scores["blend_es"],
127
+ "ptos_blend_es": ptos_blend_es,
128
  "total_estereotipos": team_scores["estereotipos"],
129
+ "ptos_estereotipos": ptos_estereotipos,
130
  "total_include": team_scores["include"],
131
+ "ptos_include": ptos_include,
132
+ "ptos_total": ptos_total,
133
  }
134
 
135
  team_leaderboard.append(team_row_data)
136
 
137
+ # Create DataFrame and sort by total points (ptos_total) instead of just arena
138
  if team_leaderboard:
139
  team_df = pd.DataFrame(team_leaderboard)
140
+ team_df.sort_values("ptos_total", ascending=False, inplace=True)
141
  return team_df
142
  else:
143
  return pd.DataFrame()
 
151
  personal_leaderboard_df = pd.read_csv(LEADERBOARD_PERSONAL_CSV)
152
  team_leaderboard_df = get_team_leaderboard(personal_leaderboard_df)
153
  team_leaderboard_df.to_csv(LEADERBOARD_EQUIPOS_CSV, index=False, encoding="utf-8")
154
+ print("Team scores calculated and saved successfully!")
155
+ print(f"Generated leaderboard with {len(team_leaderboard_df)} teams")
156
 
157
 
158
  if __name__ == "__main__":
leaderboard_equipos.csv CHANGED
@@ -1,13 +1,13 @@
1
  team_name,discord_1,discord_2,discord_3,discord_4,discord_5,total_arena,ptos_arena,total_blend_es,ptos_blend_es,total_estereotipos,ptos_estereotipos,total_include,ptos_include,ptos_total
2
- Cresia,roverico,cresia.aillm,alberto.medina,,,140,0,0,0,0,0,304,0,0
3
- TralaleloTralala-MemeAlign,andres_seba,peroloso,,,,120,0,0,0,0,0,440,0,0
4
- IberoTales,mcdaqc,,,,,118,0,0,0,0,0,449,0,0
5
- SabiduriaPopular Castellana,alvaro8gb,enrique.solera.navarro,angustias22,comasberto,,105,0,0,0,0,0,2,0,0
6
- Think Paraguayo,enpaiva93,luceldasilva,edmenciab,,,93,0,0,0,0,0,505,0,0
7
- HoCV-COL,dreamripper1,,,,,83,0,0,0,0,0,987,0,0
8
- Refranero Afro-Cubano,rasel3132,bel21093,,,,0,0,0,0,0,0,0,0,0
9
- Comida Colombia + Ecuador,pablo.ce,magodyboy,nestoralarcon.ed,diegomarquez2008,,0,0,0,0,0,0,2830,0,0
10
- Equipo LeIA,susanazhou,cosntanzapjeldres,,,,0,0,0,0,0,0,560,0,0
11
- PeruWhisper,vandread13,,,,,0,0,0,0,0,0,0,0,0
12
- Falsos_Amigos,yeisonm3011,erick bustamante,dinho9779,,,0,0,0,0,0,0,0,0,0
13
- MP,rvk6212,,,,,0,0,0,0,0,0,0,0,0
 
1
  team_name,discord_1,discord_2,discord_3,discord_4,discord_5,total_arena,ptos_arena,total_blend_es,ptos_blend_es,total_estereotipos,ptos_estereotipos,total_include,ptos_include,ptos_total
2
+ Cresia,roverico,cresia.aillm,alberto.medina,,,140,1.4,0,0.0,0,0.0,304,1.0,2.4
3
+ TralaleloTralala-MemeAlign,andres_seba,peroloso,,,,120,1.2,0,0.0,0,0.0,440,1.0,2.2
4
+ IberoTales,mcdaqc,,,,,118,1.18,0,0.0,0,0.0,449,1.0,2.1799999999999997
5
+ Think Paraguayo,enpaiva93,luceldasilva,edmenciab,,,93,0.93,0,0.0,0,0.0,505,1.0,1.9300000000000002
6
+ HoCV-COL,dreamripper1,,,,,83,0.83,0,0.0,0,0.0,987,1.0,1.83
7
+ SabiduriaPopular Castellana,alvaro8gb,enrique.solera.navarro,angustias22,comasberto,,105,1.05,0,0.0,0,0.0,2,0.01,1.06
8
+ Comida Colombia + Ecuador,pablo.ce,magodyboy,nestoralarcon.ed,diegomarquez2008,,0,0.0,0,0.0,0,0.0,2830,1.0,1.0
9
+ Equipo LeIA,susanazhou,cosntanzapjeldres,,,,0,0.0,0,0.0,0,0.0,560,1.0,1.0
10
+ Refranero Afro-Cubano,rasel3132,bel21093,,,,0,0.0,0,0.0,0,0.0,0,0.0,0.0
11
+ PeruWhisper,vandread13,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0.0
12
+ Falsos_Amigos,yeisonm3011,erick bustamante,dinho9779,,,0,0.0,0,0.0,0,0.0,0,0.0,0.0
13
+ MP,rvk6212,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0.0