Spaces:
Sleeping
Sleeping
deployed v1.0.2
Browse files
app.py
CHANGED
@@ -23,6 +23,8 @@ sns.set(style="whitegrid")
|
|
23 |
def preprocess_and_predict(model, data, match_id, features):
|
24 |
# 筛选出特定match_id的数据
|
25 |
specific_match_data = data[data['match_id'] == match_id]
|
|
|
|
|
26 |
|
27 |
if specific_match_data.empty:
|
28 |
st.write(f"No data found for match_id {match_id}.")
|
@@ -106,9 +108,19 @@ def main():
|
|
106 |
st.title('Momentum Catcher')
|
107 |
|
108 |
uploaded_file = st.file_uploader("Upload your input CSV data", type="csv")
|
109 |
-
match_id_input = st.text_input("Enter the match_id you want to analyze", "2023-wimbledon-1301")
|
110 |
|
111 |
if uploaded_file is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
repo_id = "Nagi-ovo/Momentum-XGboost"
|
113 |
filename = "xgboost.pkl"
|
114 |
|
@@ -116,8 +128,6 @@ def main():
|
|
116 |
xgb_model = load_model(repo_id, filename)
|
117 |
features = ['PAI_diff', 'normalized_rally', 'is_game_point']
|
118 |
|
119 |
-
# 读取上传的CSV文件
|
120 |
-
new_data = pd.read_csv(uploaded_file)
|
121 |
new_data['is_game_point'] = abs(new_data['p1_facing_game_point'] - new_data['p2_facing_game_point'])
|
122 |
new_data['PAI_diff'] = new_data['p1_PAI'] - new_data['p2_PAI']
|
123 |
|
|
|
23 |
def preprocess_and_predict(model, data, match_id, features):
|
24 |
# 筛选出特定match_id的数据
|
25 |
specific_match_data = data[data['match_id'] == match_id]
|
26 |
+
specific_match_data = specific_match_data.drop_duplicates(subset=['elapsed_time'], keep='first')
|
27 |
+
specific_match_data = specific_match_data[specific_match_data['server'] != 0]
|
28 |
|
29 |
if specific_match_data.empty:
|
30 |
st.write(f"No data found for match_id {match_id}.")
|
|
|
108 |
st.title('Momentum Catcher')
|
109 |
|
110 |
uploaded_file = st.file_uploader("Upload your input CSV data", type="csv")
|
111 |
+
# match_id_input = st.text_input("Enter the match_id you want to analyze", "2023-wimbledon-1301")
|
112 |
|
113 |
if uploaded_file is not None:
|
114 |
+
new_data = pd.read_csv(uploaded_file)
|
115 |
+
new_data.dropna()
|
116 |
+
|
117 |
+
# 新增:提取所有唯一的match_id
|
118 |
+
unique_match_ids = new_data['match_id'].unique()
|
119 |
+
|
120 |
+
# 新增:让用户从所有match_id中选择一个
|
121 |
+
match_id_input = st.selectbox("Select the match_id you want to analyze", unique_match_ids)
|
122 |
+
|
123 |
+
# 模型信息
|
124 |
repo_id = "Nagi-ovo/Momentum-XGboost"
|
125 |
filename = "xgboost.pkl"
|
126 |
|
|
|
128 |
xgb_model = load_model(repo_id, filename)
|
129 |
features = ['PAI_diff', 'normalized_rally', 'is_game_point']
|
130 |
|
|
|
|
|
131 |
new_data['is_game_point'] = abs(new_data['p1_facing_game_point'] - new_data['p2_facing_game_point'])
|
132 |
new_data['PAI_diff'] = new_data['p1_PAI'] - new_data['p2_PAI']
|
133 |
|