HTTP API server for DataRobot Prime.
-
- name your DataRobot Prime python code
prime.py
and put it same location intoserver.py
- name your DataRobot Prime python code
-
- run server.py
example:
# 1.
$ cp your_model_DataRobot_Prime.py ./prime.py
# 2.
$ python server.py
Check server status.
- exmaple
$ curl http://localhost:8080/status
{"status": "ok", "code": 200, "error": null}
Get prediction results by given parameters.
Response is number array style and prediction results are shown in the "predicts"
key of response.
- exmaple
# Single prediction
$ curl -XPOST http://localhost:8080/predict \
-H 'Content-Type: application/json' \
-d '{ "user_id": 100, "age": 20 }'
{"error": null, "code": 200, "predicts": [0.3727827380524341]}
# Multiple prediction
$ curl -XPOST http://localhost:8080/predict \
-H 'Content-Type: application/json' \
-d '[{ "user_id": 100, "age": 20 }, { "user_id": 200, "age": 35 }]'
{"error": null, "code": 200, "predicts": [0.3727827380524341, 0.26119423557818366]}
Get prediction results by given parameters.
Response is object array style which is created by the <key>
.
- exmaple
# Single prediction
$ curl -XPOST http://localhost:8080/predict/user_id \
-H 'Content-Type: application/json' \
-d '{ "user_id": 100, "age": 20 }'
{"error": null, "code": 200, "data": [{"user_id": 100, "predict": 0.3727827380524341}]}
# Multiple prediction
$ curl -XPOST http://localhost:8080/predict \
-H 'Content-Type: application/json' \
-d '[{ "user_id": 100, "age": 20 }, { "user_id": 200, "age": 35 }]'
{"error": null, "code": 200, "data": [{"user_id": 100, "predict": 0.3727827380524341}, {"user_id": 200, "predict": 0.26119423557818366}]}
env | description |
---|---|
DR_SERVER_PORT | HTTP port number for listening (default=8080) |
Some syntax might not be compatible to Python3 in the DataRobot Prime code. If you want to use it with Python3 environment, try below change,
sed -e "s@re.findall(ur@re.findall(r@g" -i '' ./prime.py
Check this out.