Spaces:
Runtime error
Runtime error
tabito12345678910
commited on
Commit
·
f991fae
1
Parent(s):
9af43c4
Fix field mapping for inference engine compatibility
Browse files
app.py
CHANGED
|
@@ -183,8 +183,28 @@ def predict(request: PredictionRequest):
|
|
| 183 |
detail=f"Missing required fields: {missing_en}"
|
| 184 |
)
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
# Predict
|
| 187 |
-
recommendations = engine.predict(
|
| 188 |
requested_k = int(incoming.get("topK", 30))
|
| 189 |
if len(recommendations) > requested_k:
|
| 190 |
recommendations = recommendations[:requested_k]
|
|
|
|
| 183 |
detail=f"Missing required fields: {missing_en}"
|
| 184 |
)
|
| 185 |
|
| 186 |
+
# Map fields to match inference engine expectations
|
| 187 |
+
mapped_data = {
|
| 188 |
+
'INDUSTRY': incoming['INDUSTRY'],
|
| 189 |
+
'EMPLOYEE_RANGE': incoming['EMPLOYEE_RANGE'],
|
| 190 |
+
'FRIDGE_RANGE': incoming['FRIDGE_RANGE'],
|
| 191 |
+
'PAYMENT_METHOD': incoming['PAYMENT_METHOD'],
|
| 192 |
+
'PREFECTURE': incoming['PREFECTURE'],
|
| 193 |
+
'FIRST_YEAR': incoming['FIRST_YEAR'],
|
| 194 |
+
'FIRST_MONTH': incoming['FIRST_MONTH'],
|
| 195 |
+
'LAT': incoming['LAT'],
|
| 196 |
+
'LONG': incoming['LONG'],
|
| 197 |
+
'DELIVERY_NUM': incoming['DELIVERY_NUM'],
|
| 198 |
+
'TOTAL_VOLUME': incoming['DELIVERY_NUM'], # Map DELIVERY_NUM to TOTAL_VOLUME
|
| 199 |
+
'MEDIAN_GENDER_RATIO': incoming['MEDIAN_GENDER_RATIO'],
|
| 200 |
+
'MODE_TOP_AGE_RANGE_1': incoming['MODE_TOP_AGE_RANGE_1'],
|
| 201 |
+
'MODE_TOP_AGE_RANGE_2': incoming['MODE_TOP_AGE_RANGE_2'],
|
| 202 |
+
'MODE_TOP_AGE_RANGE_3': incoming['MODE_TOP_AGE_RANGE_3'],
|
| 203 |
+
'topK': incoming.get('topK', 30)
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
# Predict
|
| 207 |
+
recommendations = engine.predict(mapped_data)
|
| 208 |
requested_k = int(incoming.get("topK", 30))
|
| 209 |
if len(recommendations) > requested_k:
|
| 210 |
recommendations = recommendations[:requested_k]
|