This is a simple project to demonstrate how creme may be used to build a "real-time" machine learning app. The idea is to predict the duration of LoL matches using information that is available at the start of the match. Once the match ends, the true duration is used to update the model.
The goal of this project is to demonstrate that online learning is easy to put in place. Indeed predicting and training are both done inside web requests.
- The machine learning model is stored in
core/management/commands/add_models.py - Predictions happen in the
queue_matchfunction ofcore/services.py - Training happens in the
try_to_end_matchfunction ofcore/services.py - The average error is computed in the
indexfunction ofcore/views.py
Create an .env file with the following structure:
RIOT_API_KEY=https://developer.riotgames.com/Next, create a local machine named dev and connect to it.
>>> docker-machine create dev
>>> eval "$(docker-machine env dev)"Now you can build the stack.
docker-compose buildYou can then start the stack.
docker-compose docker-compose.dev.yml up -dYou only have to build the stack once. However you have to rebuild it if you add or modify a service. You can now navigate to the following pages:
localhost:8000for the applocalhost:8082for Redis Commander
Run docker-compose down to spin the stack down.
docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumesCreate an .env file with the following structure:
SECRET_KEY=Keep_it_secret,_keep_it_safe
RIOT_API_KEY=https://developer.riotgames.com
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
REDIS_PASSWORD=redis
ADMIN_PASSWORD=cremeRun the following command to create a DigitalOcean droplet named prod. Replace the variables as you wish (for example $DIGITALOCEAN_SIZE could be s-1vcpu-1gb and region could be nyc3). Run docker-machine -h for more details.
>>> docker-machine create --driver digitalocean
--digitalocean-access-token $DIGITALOCEAN_ACCESS_TOKEN
--digitalocean-size $DIGITALOCEAN_SIZE
--digitalocean-region $DIGITALOCEAN_REGION
prodYou can now run docker-machine ls to see the instance you just created. Next run the following commands to deploy the app.
>>> eval "$(docker-machine env prod)"
>>> docker-compose build
>>> docker-compose up -dFinally run docker-machine ip prod to get the IP address of the production instance. If you want to check out the logs run docker-compose logs --tail=1000.
For more information about deploying a Django app with Docker check out this down to earth post.


