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

Update elo.py

Browse files
Files changed (1) hide show
  1. elo.py +4 -4
elo.py CHANGED
@@ -29,16 +29,16 @@ 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, 'rating'].iloc[0]
33
- loser_old_rating = ratings_df.loc[ratings_df == loser, '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, 'rating'] = winner_new_rating
41
- ratings_df.loc[ratings_df == loser, '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 == 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)