liveBook · Manning

Flask

As explained in Fight Fraud with Machine Learning

Flask is a lightweight Python web framework for building web applications and HTTP services.

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

How Fight Fraud with Machine Learning covers it

How deep it goes
Shows the complete inference route from artifact loading and preprocessing through thresholding, output formatting, and HTTP serving.
Examples
Uses a /predict endpoint that classifies incoming transactions as Genuine or Fraud.
What it assumes
Assumes a trained model, saved model artifact, engineered features, and an established prediction threshold.
What you can do after
Operate a Python ML service that preprocesses transaction payloads, performs inference, and returns fraud predictions.
How it connects
Links model inference with random forests, feature engineering, JSON POST requests, model artifacts, and Docker.

Also explained in

Compare how 6 books explain Flask →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.