Skip to content
Snippets Groups Projects
Commit 457ea41e authored by maeries's avatar maeries
Browse files

added k factor validation and set k accordingly

parent 20836cf4
Branches
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ from tools import *
from world_ranking_list import get_world_ranking_html
# Constants for Elo calculation
K_FACTOR = 10
K_FACTOR = 15
INITIAL_ELO = 1500 # Starting Elo for all teams
......@@ -467,6 +467,30 @@ class EloSystem:
dpi=100)
plt.close()
def optimize_k(self):
self.load_and_process_csv_files()
error_history = []
for comp in self.competition_history:
if self.get_competition_name(comp) in ("DE", "EA", "AT", "NL", "AA", "ES", "UK", "IT", "CZ", "CH"):
if 2020 > self.get_competition_date(comp).year > 2016:
results = self.competition_history[comp]['results']
error = 0
for result in results:
error = error + abs(result[3] / K_FACTOR)
error = error / len(results)
error_history.append(error)
pass
# calculate RMSE of the list of error
squared_errors = [error ** 2 for error in error_history]
mean_squared_error = sum(squared_errors) / len(squared_errors)
rmse = math.sqrt(mean_squared_error)
print(f"K of {K_FACTOR} results in a prediction RMSE of {rmse}")
def run_optimize_k():
elo_system = EloSystem('csv_files', 'public/elo_website_combustion', "combustion")
elo_system.optimize_k()
def main():
"""Main function to run the Elo ranking system"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment