32. Data for machine learning
A model is only as good as the data it learned from and the data it is given in production. Compute features as they stood at the time, freeze the training set as a version you can rebuild, compute features the same way for training and scoring, and keep the lineage back to the source and to people's choices about their data.
The clip follows Harbour Mutual's fraud model. Claims and policies in silver, and the CRM's flag of the customers who said no to their data training models. Three features computed as they stood on the day each claim was reported. Training set v1 frozen with its fingerprint, the opted-out customers' claims left out. Then production: the claims system's own code computes two features differently, every production claim's score drifts upward and more claims are flagged. A feature store gives training and scoring one definition, and the scores fall back in line. Last, the lineage from the model back to the source columns in three systems and the consent flag.
The idea: the model learns what the data says
Harbour Mutual's fraud team wants a model that flags suspicious claims as they are reported. Alex does not build the model; Alex builds what it stands on. Four ideas carry it:
- Features from silver. A feature is a number the model reads, such as the customer's prior claims. It is computed from silver, where the data is typed, de-duplicated and conformed, never from raw files or from a report.
- Point in time. Each feature is computed as it stood when the prediction would have been made: the day the claim was reported. A feature that reads anything learned later, such as the final payment or the rejection, leaks the future: the model looks brilliant in training and fails in production.
- A versioned training set. The rows the model learned from are frozen as a data product with a version: a cut-off, the feature definitions and a fingerprint of the rows. Built again next year, it gives the same rows, so the model can be explained and retrained.
- One definition for training and serving. When production computes a feature differently from training, the model's inputs move while the model stays the same: training/serving skew. A feature store keeps one definition of each feature and serves the same values to both.
A worked example: the fraud model's training set
Training set v1 holds the 30 claims reported up to 2025-06-30, without the 9 claims of customers who said no to model training. Its fingerprint is 06253112: built on 2025-07-01 and again on 2026-10-18, the rows are the same.
WITH opted_out(customer_id) AS (VALUES (4), (13), (22), (31), (40)),
claim_facts AS (
SELECT c.claim_id, c.claim_number, p.customer_id, p.start_date, c.loss_date, c.reported_date
FROM claims c JOIN policies p ON p.policy_id = c.policy_id
)
SELECT f.claim_number,
(SELECT COUNT(*) FROM claim_facts o
WHERE o.customer_id = f.customer_id AND o.claim_id <> f.claim_id
AND o.reported_date < f.reported_date AND o.reported_date >= f.reported_date - 365) AS prior_claims,
f.loss_date - f.start_date AS policy_age_days,
f.reported_date - f.loss_date AS report_delay_days,
COALESCE((d.doc ->> 'fraud_flag')::BOOLEAN, FALSE) AS fraud
FROM claim_facts f
LEFT JOIN claim_documents d ON d.claim_id = f.claim_id
WHERE f.reported_date <= DATE '2025-06-30'
AND f.customer_id NOT IN (SELECT customer_id FROM opted_out)
ORDER BY f.claim_id| Feature | Points |
|---|---|
| prior_claims | 25 a claim, at most 3 |
| policy_age_days | 30 when under 60 |
| report_delay_days | 20 when over 30 |
In production, 21 claims arrived after the cut-off. Scored with the features as training defined them, 6 are flagged; scored with the claims system's own calculation, 13. Nobody changed the model: the serving code counts the claim being scored among the prior claims, and measures the policy's age to the report date instead of the loss.
Why it matters for Alex
When a model flags the wrong claims, the first question is never about the algorithm; it is "what was it trained on, and what is it given now?" With point-in-time features, a versioned training set and one definition in a feature store, Alex can answer both in an afternoon. Without them, nobody can rebuild what the model learned, and a customer who said no cannot be shown to have been left out.
| Obligation | In short | Where it is written |
|---|---|---|
| Which insurance models are high-risk | AI systems intended for risk assessment and pricing in relation to natural persons in life and health insurance are high-risk; the list names no other insurance lines, and it excludes fraud detection only from its credit-scoring point. | EU AI Act (Regulation (EU) 2024/1689), Annex III, point 5(c), read with Article 6(2); fraud exclusion in point 5(b) |
| Governed training data | Training, validation and testing data of a high-risk system follow data governance practices (design choices, collection and origin, preparation such as labelling and cleaning, examination for bias), and are relevant, sufficiently representative and, as far as possible, free of errors and complete for the intended purpose. | EU AI Act, Article 10(2) and (3) |
| Datasheets for the training data | The technical documentation of a high-risk system describes its training data sets: their provenance, scope and main characteristics, how the data was obtained and selected, and how it was labelled and cleaned. | EU AI Act, Article 11(1) and Annex IV, point 2(d) |
| Logs over the system's lifetime | A high-risk system technically allows the automatic recording of events (logs) over its whole lifetime, for traceability. | EU AI Act, Article 12(1) |
| When the high-risk duties apply | The obligations for high-risk systems listed in Annex III apply from 2 December 2027; the regulation as first adopted set 2 August 2026, and the date was moved by the Digital Omnibus on AI. | EU AI Act, Article 113, as amended by Regulation (EU) 2026/1744 |
Where it goes wrong
- Features from today's tables. The final payment or the claim's status used as a feature: perfect in training, useless when the claim is reported.
- A training set nobody can rebuild. "The last twelve months" queried again next year gives different rows, and the model cannot be explained.
- Two teams, two calculations. The data scientists' notebook and the claims system's code compute the same feature differently, and the scores drift without anyone changing the model.
- Consent in a document. A list of customers who opted out, kept in a spreadsheet the pipeline never reads.
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
Point in time, or a leak?
For each candidate feature of the fraud model, decide whether it is safe to train on or leaks the future.
Can the training set be rebuilt?
For each recipe, decide whether the training set it makes can be rebuilt from its version, giving the same rows on another day.
Find the skew and its cause
Production scores have drifted. Compare each feature as training computed it with the claims system's value for the same production claims, and name what is different.
Who is in training set v1?
Training set v1 takes the claims reported up to 2025-06-30, without the claims of customers who said no to model training (customers 4, 13, 22, 31, 40). Decide for each claim.
On Azure
The same pieces on Azure:
- Azure Databricks: Databricks Feature Store in Unity Catalog. Features are feature tables (Delta tables with a primary key) or declarative Feature Views; point-in-time joins build training sets as of each label's time; a model trained on them records its lineage to the features and looks up the same features when it serves, from the Online Feature Store (built on Lakebase). That is the end of training/serving skew by design.
- Azure Machine Learning: a managed feature store with feature sets, point-in-time retrieval for training data, and materialisation for serving; it is the feature store to use beside Microsoft Fabric.
- Microsoft Fabric: data science in Fabric tracks experiments and registers models with MLflow, keeps features as Delta tables in a lakehouse, and scores in batch with PREDICT. Fabric has no feature store of its own, so one definition per feature is kept in the lakehouse's gold tables or in Azure Machine Learning's feature store.
- MLflow (in both Databricks and Fabric) records each training run's parameters, metrics and input datasets, so a model version points back to the training set version it learned from.
Keep the consent flags in the customer domain's own data, catalogued in Purview like any other column, so the lineage from a model reaches them.
Take it to work
Training data sheet
Describe the data a model learns from and is given in production.
The prediction
- What the model predicts, and when the prediction is made
Features
- Each feature, its definition and its source columns
- As of which moment each is computed
Training set version
- Cut-off, feature definitions' version, fingerprint
- Rows left out, and why (consent, cut-off)
Serving
- Where production gets each feature
- How training and serving share one definition
Lineage
- From the model back to the source columns and the consent flags
Tools in this chapter
- Lineage explorer · Trace a number back to its sources, or a change forward to everything it breaks.
Terms taught here: FeatureFeature storePoint-in-time correctnessTraining/serving skew