Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,23 +41,22 @@ def sale_pred_batch():
|
|
| 41 |
predicted_sale = model.predict(input_data).tolist()
|
| 42 |
print("Predicted Sales Length:", len(predicted_sale))
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
print("
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
print("Response:", response)
|
| 52 |
-
repshape = {'input_shape': input_data.shape, 'predicted_count': len(predicted_sale)}
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
'predictions': response,
|
| 59 |
-
'metadata': repshape
|
| 60 |
-
})
|
| 61 |
|
| 62 |
|
| 63 |
|
|
|
|
| 41 |
predicted_sale = model.predict(input_data).tolist()
|
| 42 |
print("Predicted Sales Length:", len(predicted_sale))
|
| 43 |
|
| 44 |
+
# Add predictions to input data
|
| 45 |
+
input_data['Predicted_Sale'] = predicted_sale
|
| 46 |
+
print("Input Data with Predictions:", input_data.head())
|
| 47 |
|
| 48 |
+
# Group by Store_Id and sum the predicted sales
|
| 49 |
+
grouped_sales = input_data.groupby('Store_Id')['Predicted_Sale'].sum().to_dict()
|
| 50 |
+
print("Grouped Sales:", grouped_sales)
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
# Create response
|
| 53 |
+
response = {
|
| 54 |
+
'store_sales': {store_id: round(float(sale), 2) for store_id, sale in grouped_sales.items()}
|
| 55 |
+
}
|
| 56 |
+
print("Final Response:", response)
|
| 57 |
|
| 58 |
+
return jsonify(response)
|
| 59 |
+
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
|