Nagi-ovo commited on
Commit
639ccd9
·
1 Parent(s): 7456358

deployed v1.0.3

Browse files
app.py CHANGED
@@ -65,19 +65,27 @@ def plot_results(specific_match_data, positive_class_probabilities, match_id, sh
65
  )
66
 
67
  if show_momentum:
68
- # 计算并绘制Momentum
69
- window_size = 3
70
- padded_probabilities = np.pad(positive_class_probabilities, (window_size//2, window_size//2), 'edge')
71
- momentum = np.convolve(padded_probabilities, np.ones(window_size)/window_size, mode='same')[:len(specific_match_data)]
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- # 创建平滑曲线
74
  X_smooth = np.linspace(specific_match_data['elapsed_time'].min(), specific_match_data['elapsed_time'].max(), 300)
75
- spline = make_interp_spline(specific_match_data['elapsed_time'], momentum, k=3) # k是平滑曲线的强度
76
  momentum_smooth = spline(X_smooth)
77
 
78
- # 绘制Momentum的平滑曲线下面积,半透明
79
  plt.fill_between(X_smooth, momentum_smooth, color='green', alpha=0.3)
80
- # 也可以选择绘制平滑曲线的边界,如果需要
81
  plt.plot(X_smooth, momentum_smooth, color='green', label='Momentum')
82
 
83
  # 标记set_no和game_no变化的时刻
 
65
  )
66
 
67
  if show_momentum:
68
+ # 修改动能计算逻辑,以确保长度一致
69
+ adjusted_probabilities = []
70
+ for i in range(1, len(positive_class_probabilities)):
71
+ # 使用当前点和前一个点的概率值,假定下一个点的概率为0.5
72
+ if i < len(positive_class_probabilities) - 1:
73
+ next_prob = 0.5 # 对于除最后一个点外的所有点,假定下一个点的概率为0.5
74
+ else:
75
+ next_prob = positive_class_probabilities[i] # 对于最后一个点,使用其本身的概率
76
+ adjusted_probabilities.append((positive_class_probabilities[i-1] + positive_class_probabilities[i] + next_prob) / 3)
77
+
78
+ # 对于第一个点,我们可以选择使用它自己的概率,因为没有前一个点
79
+ adjusted_probabilities.insert(0, (positive_class_probabilities[0] + 0.5) / 2) # 在开始处插入
80
+
81
+ # 确保adjusted_probabilities的长度与specific_match_data['elapsed_time']一致
82
+ momentum = np.array(adjusted_probabilities[:len(specific_match_data)])
83
 
 
84
  X_smooth = np.linspace(specific_match_data['elapsed_time'].min(), specific_match_data['elapsed_time'].max(), 300)
85
+ spline = make_interp_spline(specific_match_data['elapsed_time'], momentum, k=3)
86
  momentum_smooth = spline(X_smooth)
87
 
 
88
  plt.fill_between(X_smooth, momentum_smooth, color='green', alpha=0.3)
 
89
  plt.plot(X_smooth, momentum_smooth, color='green', label='Momentum')
90
 
91
  # 标记set_no和game_no变化的时刻
data/proc-2017-frenchopen-man.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/proc-2023-usopen-man.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/proc-2023-wimbledon-man.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/proc-2023-wimbledon-woman.csv ADDED
The diff for this file is too large to render. See raw diff