Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -58,18 +58,13 @@ def predict_total_sales_batch():
|
|
| 58 |
file = request.files['file']
|
| 59 |
input_data = pd.read_csv(file)
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
# Convert log sales to actual sales
|
| 65 |
-
predicted_sales = np.exp(predicted_log_sales)
|
| 66 |
-
predicted_sales = [round(float(s), 2) for s in predicted_sales]
|
| 67 |
|
| 68 |
return jsonify({'Predicted Sales for Each Row': predicted_sales})
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
output_dict = dict(zip(Product_Id, predicted_sales)) # Use actual sales total
|
| 73 |
|
| 74 |
# Return the predictions dictionary as a JSON response
|
| 75 |
return output_dict
|
|
|
|
| 58 |
file = request.files['file']
|
| 59 |
input_data = pd.read_csv(file)
|
| 60 |
|
| 61 |
+
# Make predictions for the batch data and convert raw predictions into a readable format
|
| 62 |
+
predicted_sales = [x for x in model.predict(input_data.drop("Product_Id",axis=1)).tolist()]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
return jsonify({'Predicted Sales for Each Row': predicted_sales})
|
| 65 |
|
| 66 |
+
product_id = input_data.Product_Id.values.tolist()
|
| 67 |
+
output_dict = dict(zip(product_id, predicted_sales))
|
|
|
|
| 68 |
|
| 69 |
# Return the predictions dictionary as a JSON response
|
| 70 |
return output_dict
|