Flask is a lightweight Python web framework for turning model inference code into a service that accepts transaction data and returns fraud predictions. section 3.8.2
A Flask fraud-prediction service follows a direct inference pipeline:
- Load the saved random forest, its decision threshold, and the ordered feature names from a model artifact. section 3.8.2
- Convert incoming transaction payloads into the engineered and ordered features expected by the model. section 3.8.2
- Run probability-based inference, apply the selected threshold, and map numeric predictions to human-readable Genuine or Fraud labels. section 3.8.2
- Expose the workflow through a POST /predict route and run the application on a configured host and port. section 3.8.2
Transaction fraud endpoint
A client sends transaction data as a JSON POST request to /predict. The service preprocesses the transaction, invokes the random forest, applies its threshold, and returns formatted fraud labels. section 3.8.2 section 3.9
Figure 3.26 Steps in deploying a trained random forest model using Python, Flask, and Docker.
Trace the deployment path from a trained random forest through Python and Flask to a Dockerized service. section 3.8





