rwitz commited on
Commit
a7460e5
1 Parent(s): 0c87228

Update elo.py

Browse files
Files changed (1) hide show
  1. elo.py +5 -4
elo.py CHANGED
@@ -29,16 +29,17 @@ def update_elo_ratings(ratings_dataset, winner, loser, k_factor=32):
29
  ratings_df = pd.DataFrame(ratings_dataset)
30
 
31
  # Extract old ratings
32
- winner_old_rating = ratings_df.loc[ratings_df == winner, 'elo_rating'].iloc[0]
33
- loser_old_rating = ratings_df.loc[ratings_df == loser, 'elo_rating'].iloc[0]
 
34
 
35
  # Calculate new ratings
36
  winner_new_rating = calculate_elo(winner_old_rating, loser_old_rating, 1, k_factor)
37
  loser_new_rating = calculate_elo(loser_old_rating, winner_old_rating, 0, k_factor)
38
 
39
  # Update the DataFrame
40
- ratings_df.loc[ratings_df == winner, 'elo_rating'] = winner_new_rating
41
- ratings_df.loc[ratings_df == loser, 'elo_rating'] = loser_new_rating
42
 
43
  # Convert the DataFrame back to a Hugging Face dataset
44
  updated_ratings_dataset = Dataset.from_pandas(ratings_df)
 
29
  ratings_df = pd.DataFrame(ratings_dataset)
30
 
31
  # Extract old ratings
32
+ winner_old_rating = ratings_df.loc[ratings_df['bot_name'] == winner, 'elo_rating'].iloc[0]
33
+ loser_old_rating = ratings_df.loc[ratings_df['bot_name'] == loser, 'elo_rating'].iloc[0]
34
+
35
 
36
  # Calculate new ratings
37
  winner_new_rating = calculate_elo(winner_old_rating, loser_old_rating, 1, k_factor)
38
  loser_new_rating = calculate_elo(loser_old_rating, winner_old_rating, 0, k_factor)
39
 
40
  # Update the DataFrame
41
+ ratings_df.loc[ratings_df['bot_name'] == winner, 'elo_rating'] = winner_new_rating
42
+ ratings_df.loc[ratings_df['bot_name'] == loser, 'elo_rating'] = loser_new_rating
43
 
44
  # Convert the DataFrame back to a Hugging Face dataset
45
  updated_ratings_dataset = Dataset.from_pandas(ratings_df)