A machine learning service exposes a trained model through a web endpoint: it loads the saved model artifact, transforms incoming transaction data into ordered features, runs inference, and returns a readable fraud result. section 3.8.2 section 3.9
A practical deployment workflow includes:
- Save the random forest, its ordered feature names, and its decision threshold as a model artifact. section 3.8.2 section 3.9
- Convert raw transaction fields into derived numerical features and the exact feature order expected by the model. section 3.8.2
- Apply the model threshold to prediction probabilities, then map numeric outputs to labels such as Genuine or Fraud. section 3.8.2
- Expose prediction through Flask, package the service in a Docker container, and accept JSON POST requests. section 3.8 section 3.9
Live fraud prediction
A JSON payload containing a raw transaction is posted to the /predict endpoint. The service derives additional balance features, predicts Fraud, and returns a response in approximately 4 milliseconds. section 3.8.4
Figure 3.26 Steps in deploying a trained random forest model using Python, Flask, and Docker.
Use the deployment diagram to follow the path from a trained random forest through Python inference, Flask, Docker, and online prediction. section 3.8
