liveBook · Manning

Machine learning service

As explained in Fight Fraud with Machine Learning

A machine learning service is a software service that exposes machine-learning model functionality for processing requests and returning predictions.

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

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains deployment through artifact loading, preprocessing, inference, post-processing, Flask routing, Docker packaging, and live requests.
Examples
Uses a transaction dataset, a JSON payload, a /predict endpoint, and a Dockerized random forest returning Fraud.
What it assumes
Assumes a trained model, engineered features, a saved artifact, and a selected prediction threshold.
What you can do after
Build it from scratch as a Flask and Docker service that accepts transaction JSON and returns fraud predictions.
How it connects
Connects model inference, feature engineering, random forests, Flask, Docker, JSON, and threshold selection.

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.