A pure python collaborative filtering recommendation model to produce a product recommendation for an e-commerce shop. Service can be called via REST API and is deployed in a Docker container.
- Make sure to download the OnlinRetail.csv from https://www.kaggle.com/vijayuv/onlineretail/notebooks and place it into a dir called "data" in the project root
pip install .
prep
uvicorn main:app --app-dir ./src --host 0.0.0.0 --port 8083 --reload
docker run -p 8083:8083 steffenkk/recommender-app:latest
Fake a clients request to get a recommendation from the service:
make curl USER=x
Here x is an integer and a corresponding json file is in the users dir. The json content is needed, since it provides the past orders of the user for the recommendaiton. You can pass an arbitrary user to the model, but you must include his or her orders in the request body.
Thanks to FastAPI, docs are automatically generated. You can access them here: \n
python -m pytest
This will split the data set into train (80 %) and test (20 %), run the Item to Item Similiarity with different model params, create recommendatoins for approximately 1300 users and compare the results to the test data. Subsequently Precision, Recall and F-Score will be calculated. 20 different runs will be conducted. This can take a long time. Go and get your self some coffee, lunch or both ^^.
python sricpts/evaluate.py
checkout the diagrams in the docs. For instance uml sequence at API Call: