Update README.md
Browse files
README.md
CHANGED
|
@@ -16,6 +16,99 @@ The backend is designed to be consumed by the **frontend Streamlit app** (`mwill
|
|
| 16 |
|
| 17 |
---
|
| 18 |
|
| 19 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
Base URL: https://mwill-aimission-sales-forecast-model.hf.space/
|
|
|
|
| 16 |
|
| 17 |
---
|
| 18 |
|
| 19 |
+
## Live API Endpoints
|
| 20 |
+
|
| 21 |
+
Base URL: https://mwill-aimission-sales-forecast-model.hf.space/
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
### 1. Root – Welcome
|
| 25 |
+
`GET /`
|
| 26 |
+
Returns a welcome message confirming the API is live.
|
| 27 |
+
|
| 28 |
+
Example:
|
| 29 |
+
```bash
|
| 30 |
+
curl https://mwill-aimission-sales-forecast-model.hf.space/
|
| 31 |
+
|
| 32 |
+
Response:
|
| 33 |
+
"Welcome to the SuperKart Sales Forecasting API!"
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
### 2. Health Check
|
| 37 |
+
GET /health
|
| 38 |
+
Returns a simple status object to confirm the service is running.
|
| 39 |
+
|
| 40 |
+
Example:
|
| 41 |
+
curl https://mwill-aimission-sales-forecast-model.hf.space/health
|
| 42 |
+
Response:
|
| 43 |
+
{"status": "ok"}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
### 3. Endpoint List
|
| 47 |
+
GET /endpoints
|
| 48 |
+
Lists all available API endpoints and their descriptions.
|
| 49 |
+
Example:
|
| 50 |
+
curl https://mwill-aimission-sales-forecast-model.hf.space/endpoints
|
| 51 |
+
|
| 52 |
+
Response:
|
| 53 |
+
{
|
| 54 |
+
"GET /": "Welcome page",
|
| 55 |
+
"GET /health": "Simple status check",
|
| 56 |
+
"POST /v1/predict": "Send JSON; returns predicted_sales"
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
### 4. Predict Sales
|
| 60 |
+
POST /v1/predict
|
| 61 |
+
Accepts a JSON payload containing product and store attributes, calculates engineered features, preprocesses the input, and returns the predicted sales total.
|
| 62 |
+
|
| 63 |
+
Expected JSON Payload:
|
| 64 |
+
{
|
| 65 |
+
"Product_Weight": 12.0,
|
| 66 |
+
"Product_Sugar_Content": "Low Sugar",
|
| 67 |
+
"Product_Allocated_Area": 0.068,
|
| 68 |
+
"Product_MRP": 147.03,
|
| 69 |
+
"Store_Size": "Medium",
|
| 70 |
+
"Store_Location_City_Type": "Tier 2",
|
| 71 |
+
"Store_Type": "Supermarket Type2",
|
| 72 |
+
"Product_Type": "Snack Foods",
|
| 73 |
+
"Store_Id": "OUT003",
|
| 74 |
+
"Store_Establishment_Year": 1998
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
Example Request:
|
| 78 |
+
curl -X POST \
|
| 79 |
+
https://mwill-aimission-sales-forecast-model.hf.space/v1/predict \
|
| 80 |
+
-H "Content-Type: application/json" \
|
| 81 |
+
-d '{
|
| 82 |
+
"Product_Weight": 12.0,
|
| 83 |
+
"Product_Sugar_Content": "Low Sugar",
|
| 84 |
+
"Product_Allocated_Area": 0.068,
|
| 85 |
+
"Product_MRP": 147.03,
|
| 86 |
+
"Store_Size": "Medium",
|
| 87 |
+
"Store_Location_City_Type": "Tier 2",
|
| 88 |
+
"Store_Type": "Supermarket Type2",
|
| 89 |
+
"Product_Type": "Snack Foods",
|
| 90 |
+
"Store_Id": "OUT003",
|
| 91 |
+
"Store_Establishment_Year": 1998
|
| 92 |
+
}'
|
| 93 |
+
|
| 94 |
+
Example Response:
|
| 95 |
+
{
|
| 96 |
+
"predicted_sales": 7614.54
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
🛠️ Tech Stack
|
| 100 |
+
Language: Python 3.10+
|
| 101 |
+
Framework: Flask
|
| 102 |
+
ML Libraries: scikit-learn, pandas, numpy
|
| 103 |
+
Deployment: Hugging Face Spaces (Docker)
|
| 104 |
+
|
| 105 |
+
📌 Notes
|
| 106 |
+
The model is preloaded at startup for performance.
|
| 107 |
+
Feature engineering (Store_Age, Product_Allocated_Area_Sq, and Revenue_per_Allocated_Area) happens in the backend before prediction.
|
| 108 |
+
The API is stateless and ready to be integrated with any frontend or automation pipeline.
|
| 109 |
+
|
| 110 |
+
🔗 Related Project
|
| 111 |
+
Frontend Streamlit App:
|
| 112 |
+
https://huggingface.co/spaces/mwill-AImission/superkart-sales-forecast-frontend
|
| 113 |
+
|
| 114 |
|
|
|