Dacho688
commited on
Commit
·
7e4e094
1
Parent(s):
153efb4
Update readme
Browse files
README.md
CHANGED
|
@@ -7,5 +7,61 @@ sdk: docker
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
+
## ML API
|
| 11 |
+
A FastAPI enpoint serving a fitted sklearn pipeline with an ordinal logistic regression model using the
|
| 12 |
+
<a href="https://pypi.org/project/mord/">Mord Python Package</a> to predict customer's "small quantity order importance ranking (1-10)."
|
| 13 |
+
|
| 14 |
+
#### Pipeline Steps
|
| 15 |
+
1. Column Transformer<br>
|
| 16 |
+
a. Standard Scaling for numerical variables<br>
|
| 17 |
+
b. One-hot-encoding for categorical variables
|
| 18 |
+
2. Feature Selection<br>
|
| 19 |
+
a. Lasso Regression
|
| 20 |
+
3. Model <br>
|
| 21 |
+
a. Mord Ordinal Logistic Regression
|
| 22 |
+
|
| 23 |
+
The fitted pipeline is then serialized with joblib, served with Fast API (Uvicorn), containarized with Docker, and finally deployed to HuggingFace Spaces.
|
| 24 |
+
|
| 25 |
+
Prediction requests can be sent to https://dkondic-ml-api.hf.space/predict as a list of dictionaries where each dictionary is an instance to predict. Thus, prediction is possible for single instance or batch of instances. Please see <a href="https://dkondic-ml-api.hf.space/">ML API Docs</a> for more indormation.<br>
|
| 26 |
+
|
| 27 |
+
#### Request Body
|
| 28 |
+
```
|
| 29 |
+
[
|
| 30 |
+
{
|
| 31 |
+
"CUST_NBR": "string",
|
| 32 |
+
"MENU_TYP_DESC": "string",
|
| 33 |
+
"PYR_SEG_CD": "string",
|
| 34 |
+
"DIV_NBR": "string",
|
| 35 |
+
"WKLY_ORDERS": 0,
|
| 36 |
+
"PERC_EB": 0,
|
| 37 |
+
"AVG_WKLY_SALES": 0,
|
| 38 |
+
"AVG_WKLY_CASES": 0
|
| 39 |
+
}
|
| 40 |
+
]
|
| 41 |
+
```
|
| 42 |
+
#### Resonse Body
|
| 43 |
+
```
|
| 44 |
+
{
|
| 45 |
+
"prediction": [
|
| 46 |
+
0
|
| 47 |
+
]
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
#### Prediction xample using Python requests
|
| 51 |
+
```py
|
| 52 |
+
import requests
|
| 53 |
+
|
| 54 |
+
data = [
|
| 55 |
+
{"CUST_NBR":"1111",
|
| 56 |
+
"MENU_TYP_DESC":"MEXICAN",
|
| 57 |
+
"PYR_SEG_CD":"Education",
|
| 58 |
+
"DIV_NBR":"20",
|
| 59 |
+
"WKLY_ORDERS": 15,
|
| 60 |
+
"PERC_EB":0.80,
|
| 61 |
+
"AVG_WKLY_SALES":2656.04,
|
| 62 |
+
"AVG_WKLY_CASES":67.00}]
|
| 63 |
+
|
| 64 |
+
response = requests.post("https://dkondic-ml-api.hf.space/predict", json=data)
|
| 65 |
+
print(response.json())
|
| 66 |
+
```
|
| 67 |
|
|
|