Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -82,14 +82,22 @@ def predict_product_sale_price_batch():
|
|
| 82 |
|
| 83 |
# Create a dictionary of predictions with product IDs as keys
|
| 84 |
product_ids = input_data['Product_Id'].tolist() # Assuming 'id' is the product ID column
|
| 85 |
-
output_dict = dict(zip(product_ids, predicted_prices)) # Use actual prices
|
| 86 |
|
| 87 |
# Create a dictionary of predictions with Store IDs as keys
|
| 88 |
store_ids = input_data['Store_Id'].tolist()
|
| 89 |
-
output_dict = dict(zip(store_ids, predicted_prices)) # Use actual prices
|
| 90 |
|
| 91 |
-
#
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Run the Flask application in debug mode if this script is executed directly
|
| 95 |
if __name__ == '__main__':
|
|
|
|
| 82 |
|
| 83 |
# Create a dictionary of predictions with product IDs as keys
|
| 84 |
product_ids = input_data['Product_Id'].tolist() # Assuming 'id' is the product ID column
|
|
|
|
| 85 |
|
| 86 |
# Create a dictionary of predictions with Store IDs as keys
|
| 87 |
store_ids = input_data['Store_Id'].tolist()
|
|
|
|
| 88 |
|
| 89 |
+
# Build predictions with both Product and Store IDs
|
| 90 |
+
output_list = []
|
| 91 |
+
|
| 92 |
+
for pid, sid, price in zip(product_ids, store_ids, predicted_prices):
|
| 93 |
+
output_list.append({
|
| 94 |
+
"Product_Id": pid,
|
| 95 |
+
"Store_Id": sid,
|
| 96 |
+
"Predicted_Revenue": round(float(price), 2)
|
| 97 |
+
})
|
| 98 |
+
|
| 99 |
+
# Return as JSON response
|
| 100 |
+
return jsonify({"predictions": output_list})
|
| 101 |
|
| 102 |
# Run the Flask application in debug mode if this script is executed directly
|
| 103 |
if __name__ == '__main__':
|