赞
踩
这题挺有意思,没具体看比赛情况,打过比赛的人应该都知道险胜局(第二局、第五局逆转局)最影响心态的,导致第3、5局输了
模型结果证明这样的现象,会更可靠
赛题目的:分析球员的表现
为了建立球员在比赛特定时间表现力的模型,我们需要根据提供的数据选择一些关键因素来评估球员表现。我们可以选择如下几个因素:
import pandas as pd import matplotlib.pyplot as plt import numpy as np # 读取数据 df = pd.read_csv('Problem_C_Wimbledon_featured_matches.csv') # # 筛选以 "2023-wimbledon-13" 开头的 match_id # df_filtered = df[df['match_id'].str.startswith('2023-wimbledon-13')] # # 获取唯一的 match_id 并转换为列表 # match_ids = df_filtered['match_id'].unique().tolist() # for match_id in match_ids: for match_id in ["2023-wimbledon-1301", "2023-wimbledon-1401", "2023-wimbledon-1501", "2023-wimbledon-1601", "2023-wimbledon-1701"]: # 选择特定的比赛 df_match = df[df['match_id'] == match_id] # 计算每个球员的表现力 df_match['p1_performance'] = df_match['p1_ace'] + df_match['p1_winner'] - df_match['p1_unf_err'] + df_match['p1_net_pt_won'] df_match['p2_performance'] = df_match['p2_ace'] + df_match['p2_winner'] - df_match['p2_unf_err'] + df_match['p2_net_pt_won'] # 累计表现力 df_match['p1_performance_cum'] = df_match['p1_performance'].cumsum() df_match['p2_performance_cum'] = df_match['p2_performance'].cumsum() # 绘制球员表现力变化趋势图 plt.figure(figsize=(12, 6)) plt.plot(df_match['point_no'], df_match['p1_performance_cum'], label=df_match['player1'].iloc[0] + ' Performance') plt.plot(df_match['point_no'], df_match['p2_performance_cum'], label=df_match['player2'].iloc[0] + ' Performance') # 设置图表标题和标签 plt.title('Performance Over Time') plt.xlabel('Point Number') plt.ylabel('Cumulative Performance') plt.legend() plt.grid(True) # 保存球员表现力变化趋势图 plt.savefig('performance_over_time_{}.png'.format(match_id)) # 绘制比赛得分情况图 plt.figure(figsize=(12, 6)) plt.plot(df_match['point_no'], df_match['p1_points_won'].cumsum(), label=df_match['player1'].iloc[0] + ' Points Won') plt.plot(df_match['point_no'], df_match['p2_points_won'].cumsum(), label=df_match['player2'].iloc[0] + ' Points Won') # 设置图表标题和标签 plt.title('Points Won Over Time') plt.xlabel('Point Number') plt.ylabel('Cumulative Points Won') plt.legend() plt.grid(True) # 保存比赛得分情况图 plt.savefig('points_won_over_time_{}.png'.format(match_id)) plt.close()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。