Spaces:
Sleeping
Sleeping
Commit
·
4980c86
1
Parent(s):
60e1d24
Iteration 20
Browse files
app.py
CHANGED
@@ -27,18 +27,18 @@ def load_reference_data(player_id):
|
|
27 |
"""Load reference prediction data and input features"""
|
28 |
try:
|
29 |
# Read the full CSV to get both input features and prediction
|
30 |
-
ref_df = pd.read_csv(f"{player_id}.csv", encoding='utf-8')
|
31 |
|
32 |
-
#
|
33 |
-
features = ref_df[ref_df.index != 'Predicted_Cost']
|
34 |
-
|
35 |
-
print(features)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
-
return features, prediction
|
42 |
except Exception as e:
|
43 |
print(f"Could not load reference data: {e}")
|
44 |
return None, None
|
@@ -144,12 +144,15 @@ def predict_cost(user_id, mmr, comf_1, comf_2, comf_3, comf_4, comf_5):
|
|
144 |
|
145 |
print("\nComparing processed data with reference:")
|
146 |
if reference_features is not None:
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
153 |
# Load and use the model
|
154 |
model_path = Path("model/rd2l_forest.onnx")
|
155 |
if not model_path.exists():
|
|
|
27 |
"""Load reference prediction data and input features"""
|
28 |
try:
|
29 |
# Read the full CSV to get both input features and prediction
|
30 |
+
ref_df = pd.read_csv(f"{player_id}.csv", encoding='utf-8', index_col=0)
|
31 |
|
32 |
+
# Remove the prediction row and convert to a proper format
|
33 |
+
features = ref_df[ref_df.index != 'Predicted_Cost'].iloc[:, 0]
|
34 |
+
prediction = ref_df.loc['Predicted_Cost', f"{player_id}_S34"]
|
|
|
35 |
|
36 |
+
print("\nReference data loaded:")
|
37 |
+
for idx in ['mmr', 'p1', 'p2', 'p3', 'p4', 'p5', 'count', 'mean', 'std', 'min', 'max', 'sum']:
|
38 |
+
if idx in features.index:
|
39 |
+
print(f"{idx}: {features[idx]}")
|
40 |
|
41 |
+
return features, float(prediction)
|
42 |
except Exception as e:
|
43 |
print(f"Could not load reference data: {e}")
|
44 |
return None, None
|
|
|
144 |
|
145 |
print("\nComparing processed data with reference:")
|
146 |
if reference_features is not None:
|
147 |
+
our_data = processed_data.iloc[0]
|
148 |
+
for idx in ['mmr', 'p1', 'p2', 'p3', 'p4', 'p5', 'count', 'mean', 'std', 'min', 'max', 'sum']:
|
149 |
+
our_val = our_data[idx]
|
150 |
+
ref_val = reference_features[idx] if idx in reference_features.index else "N/A"
|
151 |
+
print(f"{idx}:")
|
152 |
+
print(f" Our value: {our_val}")
|
153 |
+
print(f" Ref value: {ref_val}")
|
154 |
+
if our_val != ref_val and ref_val != "N/A":
|
155 |
+
print(f" *** MISMATCH ***")
|
156 |
# Load and use the model
|
157 |
model_path = Path("model/rd2l_forest.onnx")
|
158 |
if not model_path.exists():
|