Spaces:
Runtime error
Runtime error
Add elo compute
Browse files- app.py +7 -0
- matchmaking.py +7 -0
app.py
CHANGED
@@ -17,6 +17,13 @@ envs = [
|
|
17 |
"global": None,
|
18 |
},
|
19 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
def get_env_data(env_name) -> pd.DataFrame:
|
|
|
17 |
"global": None,
|
18 |
},
|
19 |
]
|
20 |
+
matchmaking = Matchmaking()
|
21 |
+
|
22 |
+
|
23 |
+
def update_elos():
|
24 |
+
matchmaking.read_history()
|
25 |
+
matchmaking.compute_elo()
|
26 |
+
matchmaking.save_elo_data()
|
27 |
|
28 |
|
29 |
def get_env_data(env_name) -> pd.DataFrame:
|
matchmaking.py
CHANGED
@@ -61,6 +61,13 @@ class Matchmaking:
|
|
61 |
model1.games_played += 1
|
62 |
model2.games_played += 1
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
def get_model(self, name):
|
65 |
""" Return the Model with the given name. """
|
66 |
for model in self.models:
|
|
|
61 |
model1.games_played += 1
|
62 |
model2.games_played += 1
|
63 |
|
64 |
+
def save_elo_data(self):
|
65 |
+
""" Save the match history as a CSV file to the hub. """
|
66 |
+
df = pd.DataFrame(columns=['name', 'elo'])
|
67 |
+
for model in self.models:
|
68 |
+
df = pd.concat([df, pd.DataFrame([[model.name, model.elo]], columns=['name', 'elo'])])
|
69 |
+
df.to_csv('elo.csv', index=False)
|
70 |
+
|
71 |
def get_model(self, name):
|
72 |
""" Return the Model with the given name. """
|
73 |
for model in self.models:
|