Deploy Your Machine Learning Model on Docker — Part 2

Store your Machine Learning model, expose your model as an API, build a simple interface for API testing, containerise your ML model.

Chau Vinh Loi
Analytics Vidhya

--

In Part 1 of this tutorial, we have successfully stored your classification model in a local directory and finished all the works related to Jupyter Notebook for model development. From now on, the focus would be on deploying our model. To reuse the model for prediction, you can just load it up and call the predict() method as you usually do in Jupyter Notebook.

In the same folder containing the model.pkl file, create a main.py file with this code to test the model.

You can call the predict method multiple times for unseen observations without running the training process again. However, when you run this py file on the terminal, you might face the error similar to this one:

Traceback (most recent call last):
File "main.py", line 4, in <module>
from sklearn.neighbors import…

--

--