With a trained model saved, the next step is to make it operational so it can receive input data and return predictions. This chapter addresses how to expose your model's prediction capabilities over a network.
We will introduce Application Programming Interfaces (APIs) and explain their function in model serving. You will learn the fundamentals of the Flask web framework and use it to construct a basic web service. This service will load a serialized model and handle prediction requests via HTTP. Key topics include setting up Flask, defining routes for prediction, processing input data (typically JSON), and structuring the prediction response. By the end of this chapter, you will have built a simple, functional API endpoint capable of serving predictions from your machine learning model.
3.1 What is an API?
3.2 Introduction to Web Frameworks
3.3 Setting Up Flask
3.4 Creating a Basic Flask Application
3.5 Loading Your Saved Model in Flask
3.6 Defining a Prediction Endpoint
3.7 Handling Input Data (JSON)
3.8 Returning Predictions
3.9 Testing Your API Locally
3.10 Hands-on Practical: Building a Simple Flask Prediction API
© 2025 ApX Machine Learning