| import plotly.express as px | |
| from .data_utils import generate_data | |
| async def plot_ratings(criteria : str): | |
| """ | |
| Plot different ratings of the models for a given criteria on a line graph. | |
| Args: | |
| criteria (str): The criteria to plot the ratings for. | |
| """ | |
| data = await generate_data() | |
| elo_data = data[data['Criteria'] == criteria].reset_index(drop=True) | |
| elo_data.reset_index(inplace=True) | |
| elo_data['index'] = elo_data['index'].apply(lambda x: int(x/2)) | |
| elo_fig = px.line(elo_data, x='index', y='Elo', color='Model', title='Elo Ratings Over Total Votes', labels={'index': 'Total Votes', 'Elo': 'Elo Rating'}) | |
| wr_data = data[data['Criteria'] == criteria].reset_index(drop=True) | |
| wr_data.reset_index(inplace=True) | |
| wr_data['index'] = wr_data['index'].apply(lambda x: int(x/2)) | |
| wr_fig = px.line(wr_data, x='index', y='Win Rate', color='Model', title='Win Rates Over Total Votes', labels={'index': 'Total Votes', 'Win Rate': 'Win Rate'}) | |
| matches_data = data[data['Criteria'] == criteria].reset_index(drop=True) | |
| matches_data.reset_index(inplace=True) | |
| matches_data['index'] = matches_data['index'].apply(lambda x: int(x/2)) | |
| matches_fig = px.line(matches_data, x='index', y='Matches', color='Model', title='Matches Played Over Total Votes', labels={'index': 'Total Votes', 'Matches': 'Matches Played'}) | |
| return elo_fig, wr_fig, matches_fig |