src
: consists of Python scriptsconfig
: consists of configuration filesdata
: consists of dataprocessors
: consists of all scikit-learn's transformers used to process the new input
- Clone this branch:
git clone --branch bentoml_demo https://github.com/SiddharthUchil/customer_segmentation.git
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Pull data
dvc pull
To run all flows, type:
python src/main.py
To serve the trained model, run:
bentoml serve src/bentoml_app.py:service --reload
Now you should be able to interact with the API by going to http://127.0.0.1:5000 and clicking the "Try it out" button:
To send requests to the newly started service in Python, run:
python src/predict.py
Details of predict.py
:
import requests
prediction = requests.post(
"http://127.0.0.1:5000/predict",
headers={"content-type": "application/json"},
data='{"Income": 58138, "Recency": 58, "Complain": 0,"age": 64,"total_purchases": 25,"enrollment_years": 10,"family_size": 1}',
).text
print(prediction)
Output:
1
To open a Streamlit app, run:
streamlit run src/streamlit_app.py
then go to http://localhost:8501. You should see a web app like below: