Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -43,8 +43,10 @@ def predict_sales():
|
|
| 43 |
# Make a Sales prediction using the trained model
|
| 44 |
salesPrediction = model.predict(input_data).tolist()[0]
|
| 45 |
|
|
|
|
|
|
|
| 46 |
# Return the actual price
|
| 47 |
-
return jsonify({'Predicted Sales Revenue Price':
|
| 48 |
|
| 49 |
# Batch Prediction
|
| 50 |
# Define an endpoint to predict Sales revenue for a given batch of Product among the given store.
|
|
@@ -61,7 +63,8 @@ def predict_sales_batch():
|
|
| 61 |
input_data["Product_Category"] = input_data["Product_Id"].str[:2]
|
| 62 |
|
| 63 |
# Make predictions for the batch data and convert raw predictions into a readable format
|
| 64 |
-
salesPredictions = model.predict(input_data.drop("Product_Id",axis=1)).tolist()
|
|
|
|
| 65 |
product_id_list = input_data.Product_Id.values.tolist()
|
| 66 |
output_dict = dict(zip(product_id_list, salesPredictions))
|
| 67 |
|
|
|
|
| 43 |
# Make a Sales prediction using the trained model
|
| 44 |
salesPrediction = model.predict(input_data).tolist()[0]
|
| 45 |
|
| 46 |
+
predicted_revenue = round(float(salesPrediction), 2)
|
| 47 |
+
|
| 48 |
# Return the actual price
|
| 49 |
+
return jsonify({'Predicted Sales Revenue Price': predicted_revenue})
|
| 50 |
|
| 51 |
# Batch Prediction
|
| 52 |
# Define an endpoint to predict Sales revenue for a given batch of Product among the given store.
|
|
|
|
| 63 |
input_data["Product_Category"] = input_data["Product_Id"].str[:2]
|
| 64 |
|
| 65 |
# Make predictions for the batch data and convert raw predictions into a readable format
|
| 66 |
+
salesPredictions = [round(pred, 2) for pred in model.predict(input_data.drop("Product_Id", axis=1)).tolist()]
|
| 67 |
+
##salesPredictions = model.predict(input_data.drop("Product_Id",axis=1)).tolist()
|
| 68 |
product_id_list = input_data.Product_Id.values.tolist()
|
| 69 |
output_dict = dict(zip(product_id_list, salesPredictions))
|
| 70 |
|