Chapter 7. Operationalizing Machine Learning Models
All of the machine learning models presented so far in this book are written in Python. Models don’t have to be written in Python, but many are, thanks in part to the numerous world-class Python libraries available, including Pandas and Scikit-Learn. ML models written in Python are easily consumed in Python apps. Calling them from other languages such as C++, Java, and C# requires a little more work. You can’t simply call a Python function from C++ as if it were a C++ function. So how do you invoke models written in Python from apps written in other languages? Put another way, how do you operationalize Python models such that they are usable in any app on any platform written in any programming language?
The diagram on the left in Figure 7-1 shows one strategy: wrap the model in a web service and expose its functionality through a REST API. Then any client that can generate an HTTP(S) request can invoke the model. It’s relatively easy to do the wrapping with help from Python frameworks such as Flask. The web service can be hosted locally or in the cloud, and it can be containerized for easy deployment using tools such as Docker.
The diagram on the right shows another strategy—one that’s relatively new but rapidly growing in popularity. It involves exporting ...
Get Applied Machine Learning and AI for Engineers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.