Abhishek Thakur commited on
Commit
5c5968f
Β·
1 Parent(s): f53f9d6

leaderboard

Browse files
Files changed (2) hide show
  1. config.py +1 -0
  2. pages/2_πŸ“_Leaderboard.py +35 -16
config.py CHANGED
@@ -19,3 +19,4 @@ SUBMISSION_LIMIT = int(os.getenv("SUBMISSION_LIMIT"))
19
  SELECTION_LIMIT = int(os.getenv("SELECTION_LIMIT"))
20
  END_DATE = os.getenv("END_DATE")
21
  END_DATE = datetime.strptime(END_DATE, "%Y-%m-%d")
 
 
19
  SELECTION_LIMIT = int(os.getenv("SELECTION_LIMIT"))
20
  END_DATE = os.getenv("END_DATE")
21
  END_DATE = datetime.strptime(END_DATE, "%Y-%m-%d")
22
+ EVAL_HIGHER_IS_BETTER = True if int(os.getenv("EVAL_HIGHER_IS_BETTER")) == 1 else False
pages/2_πŸ“_Leaderboard.py CHANGED
@@ -21,24 +21,43 @@ def fetch_leaderboard(private=False):
21
  for submission in glob.glob(os.path.join(submissions_folder, "*.json")):
22
  with open(submission, "r") as f:
23
  submission_info = json.load(f)
24
- submissions.append(submission_info)
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  print(submissions)
27
 
28
- data_dict = {
29
- "Team Name": ["Team 1", "Team 2", "Team 3", "Team 4", "Team 5"],
30
- "Score": [0.9, 0.8, 0.7, 0.6, 0.5],
31
- "Rank": [1, 2, 3, 4, 5],
32
- "Submission Time": [
33
- "2021-01-01 00:00:00",
34
- "2021-01-01 00:00:00",
35
- "2021-01-01 00:00:00",
36
- "2021-01-01 00:00:00",
37
- "2021-01-01 00:00:00",
38
- ],
39
- }
40
- lb = pd.DataFrame(data_dict)
41
- st.table(lb)
42
 
43
 
44
  def app():
 
21
  for submission in glob.glob(os.path.join(submissions_folder, "*.json")):
22
  with open(submission, "r") as f:
23
  submission_info = json.load(f)
24
+ print(config.EVAL_HIGHER_IS_BETTER)
25
+ if config.EVAL_HIGHER_IS_BETTER:
26
+ submission_info["submissions"].sort(
27
+ key=lambda x: x["private_score"] if private else x["public_score"], reverse=True
28
+ )
29
+ else:
30
+ submission_info["submissions"].sort(key=lambda x: x["private_score"] if private else x["public_score"])
31
+ # select only the best submission
32
+ submission_info["submissions"] = submission_info["submissions"][0]
33
+ temp_info = {
34
+ "id": submission_info["id"],
35
+ "name": submission_info["name"],
36
+ "submission_id": submission_info["submissions"]["submission_id"],
37
+ "submission_comment": submission_info["submissions"]["submission_comment"],
38
+ "status": submission_info["submissions"]["status"],
39
+ "selected": submission_info["submissions"]["selected"],
40
+ "public_score": submission_info["submissions"]["public_score"],
41
+ "private_score": submission_info["submissions"]["private_score"],
42
+ "submission_date": submission_info["submissions"]["date"],
43
+ }
44
+ submissions.append(temp_info)
45
  print(submissions)
46
 
47
+ df = pd.DataFrame(submissions)
48
+ # sort by public score and then by submission_date
49
+ df = df.sort_values(
50
+ by=["public_score", "submission_date"],
51
+ ascending=True if not config.EVAL_HIGHER_IS_BETTER else False,
52
+ )
53
+ df = df.reset_index(drop=True)
54
+ df["rank"] = df.index + 1
55
+
56
+ if private:
57
+ columns = ["rank", "name", "private_score", "submission_date"]
58
+ else:
59
+ columns = ["rank", "name", "public_score", "submission_date"]
60
+ st.table(df[columns])
61
 
62
 
63
  def app():