@@ -3,16 +3,26 @@ A simple Flask application that can serve predictions machine learning model. Re
3
3
4
4
# Steps for deploying ML model
5
5
6
- 1 . Install Flask
7
- 2 . Serialise your model (this can be done using Pickle, or JobLib)
8
- 3 . [ optional] Serialise your columns
9
- 4 . Create a separate [ insert name here] .py file in the same directory as your serialised model, which will build the web service using Flask
10
- 5 . Run [ insert name here] .py file from terminal/command line
11
- 6 . Go to http address to check if its working
12
- 7 . Make a http POST call with some data, and receive the prediction back.
13
-
14
-
15
- 1 . ### Install PIP requirements
6
+ 1 . Install Flask and Docker
7
+ 2 . Serialise your scikit-learn model (this can be done using Pickle, or JobLib)
8
+ 3 . [ optional] add column names list to scikit object ex: rf.columns = [ 'Age', 'Sex', 'Embarked', 'Survived']
9
+ 4 . Create a separate flask_api.py file which will build the web service using Flask
10
+ 5 . To run python flask_api.py <port >
11
+ 6 . Go to http address to check if its working
12
+ 5 . Create a dockerfile which does the below items
13
+ 6 . Install ubuntu, python and git
14
+ 7 . Clone code repo from git or move local python code to /app in container
15
+ 8 . Set WORKDIR to /app
16
+ 9 . Install packages in requirements.xt
17
+ 10 . Expose the port for flask enpoint
18
+ 11 . Define ENTRYPOINT as python main.py 9999
19
+ 6 . Build docker image
20
+ 7 . Run docker container
21
+ 8 . Make a http POST call with some data, and receive the prediction back using postman or python requests library.
22
+ 9 . Push the docker container to docker registry / ship to production
23
+
24
+ 1 . ### Install PIP requirements
25
+ FYI: The code requries Python 3.6+ to run
16
26
```
17
27
pip install -r requirements.txt
18
28
```
@@ -68,7 +78,7 @@ A simple Flask application that can serve predictions machine learning model. Re
68
78
69
79
70
80
Appendix
71
- - http://docs.python-requests.org/en/latest/index.html
81
+ - http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests
72
82
- https://www.ibm.com/developerworks/webservices/library/ws-restful/
73
83
- https://blog.hyperiondev.com/index.php/2018/02/01/deploy-machine-learning-model-flask-api/
74
84
- https://medium.com/@amirziai/a-flask-api-for-serving-scikit-learn-models-c8bcdaa41daa
0 commit comments