A simple HTTP server that handle requests to feed a LinUCB machine learning algorithm
- Python 3 and
requirements.txtfile dependencies
pip3 install -r requirements.txt
python3 src/server.pyOtherwise, you can use docker to run it (see Dockerfile)
-
GET
/thetas: Get current thetas values -
GET
/a: Get current a values -
GET
/b: Get current b values -
GET
/arms: Get arms names -
GET
/stats: Get stats -
GET
/ping: Respond pong if API is running -
POST
/arms: Create arms (n_arms) -
POST
/reward: Send reward (arm, reward, x) -
POST
/tirages: Send tirages (generated random for moment) -
POST
/features: Add n feature(s) -
DELETE
/arms/:n: Delete arm (n)
curl -X GET \
http://127.0.0.01:8080/thetascurl -X GET \
http://127.0.0.01:8080/acurl -X GET \
http://127.0.0.01:8080/bcurl -X POST \
http://localhost:8080/tirages \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'n=4&X=%7B%20%22a%22%3A%20%5B100%2C%207%5D%2C%20%22b%22%3A%20%5B10%2C%2044%5D%2C%20%22e%22%3A%20%5B100%2C%2091%5D%2C%20%22f%22%3A%20%5B10%2C%2092%5D%20%7D'curl -X POST \
http://localhost:8080/reward \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'arm=e&reward=100&x=0.94327796315973622&x=0.98546216493058936'curl -X POST \
http://127.0.0.01:8080/arms \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'arms=e&arms=f'curl -X DELETE \
http://localhost:8080/arms/ecurl -X POST \
http://127.0.0.01:8080/features \
-H 'content-type: application/x-www-form-urlencoded' \
-d n=1curl -X GET \
http://127.0.0.01:8080/statscurl -X GET \
http://127.0.0.01:8080/pingpip install virtualenv
virtualenv venv
source venv/bin/activate
deactivate
pip freeze > requirements.txt
pip install -r requirements.txt