Everything you have learnt so far you have applied to a single company: an online shop. It is a good training ground, but it carries a risk: believing that NovaMarket's architecture is the architecture. A bank that must decide within 200 milliseconds whether to authorise a payment cannot wait for the nightly load; a hospital cannot simply copy its data into a lake; a factory receives more sensor readings in an hour than NovaMarket receives events in a day.

This lesson goes through five sectors using the same template, so that you can compare them: what problem they had, what data they had available, what architecture they chose, what the technical core of the solution looks like, what they achieved and what they learnt. At the end, a cross-sector table and a list of patterns will show you that, beneath the diversity, the important decisions are repeated.

About these cases. The organisations, figures and results are fictitious. They are typical cases, built from patterns common in each sector, not descriptions of any real company. The code snippets are illustrative: they show the core of each solution, but they use tables that do not exist in your practice environment and are not meant to be run.

How to read a case study

You do not read a case study to copy the solution, but to understand why it was chosen. With any case, whether from this lesson or from a conference, ask yourself five questions:

Question What it reveals
Which business decision does it improve? Whether the project made sense
What latency does that decision require? Batch or streaming; it is the decision that most shapes the architecture
What data is there, and of what quality? The real ceiling on what can be achieved
What happens when the system gets it wrong? The level of rigour, human oversight and regulation required
What do they not mention? Costs, previous failures, the integration work

The last one is the most useful with cases published by companies and vendors, which only tell of their successes.

Finance: real-time fraud detection

Context and problem

Litoral Bank, a medium-sized bank with 3 million cards, processes about 12 million transactions a day. Its anti-fraud system was a set of fixed rules run in batches every hour: by the time it detected a compromised card, the fraudster had been shopping for forty minutes. In addition, the rules blocked many legitimate transactions, with the resulting annoyance for customers.

The requirement is set by the business: the decision to authorise or not must be made while the customer is waiting at the card terminal, in less than 200 milliseconds.

Data

  • Card transactions: amount, merchant, category, country, channel, timestamp.
  • Historical profile of each card: average spend, usual merchants and countries, times of day.
  • Device and location for online purchases.
  • Labels: the transactions confirmed as fraud, known weeks later, when the customer files a claim.

Architecture

flowchart LR
    TPV[Card terminals and gateways] --> K[Kafka: transactions]
    K --> S[Streaming engine:<br>windowed features]
    P[(Profile store<br>NoSQL key-value)] --> S
    S --> M[Rules + model]
    M -->|approve / hold| AUT[Authorisation system]
    M --> A[Kafka: alerts] --> AN[Fraud analysts]
    K --> L[(Data lake)]
    AN -->|confirmation| L
    L -->|nightly batch training| M
    L -->|recalculated profiles| P

It is NovaMarket's fraud architecture (lesson 01-04), taken to the extreme: the decision path is streaming, but the profiles and the model are recalculated in batches on the lake.

Technical solution

The core is to calculate, for each card, features describing what has happened in the last few minutes and compare them with its profile. It is the rule from lesson 03-05 (three purchases in ten minutes), generalised:

# Illustrative: not runnable with the course data
transactions = (
    spark.readStream.format("kafka")
    .option("kafka.bootstrap.servers", "kafka:9092")
    .option("subscribe", "transactions")
    .load()
    .select(F.from_json(F.col("value").cast("string"), TRANSACTION_SCHEMA).alias("tx"))
    .select("tx.*")
)

features = (
    transactions
    .withWatermark("event_time", "2 minutes")
    .groupBy(F.window("event_time", "10 minutes", "1 minute"), "card_id")
    .agg(F.count("*").alias("num_transactions"),
         F.sum("amount").alias("window_amount"),
         F.approx_count_distinct("country").alias("distinct_countries"))
)

profiles = spark.read.parquet("s3://litoral-lake/gold/card_profile")   # static table

suspicious = (
    features.join(profiles, "card_id")
    .where((F.col("distinct_countries") >= 2)
           | (F.col("window_amount") > 5 * F.col("avg_daily_spend")))
)
  • The ten-minute sliding window that moves forward every minute and the watermark are the concepts from lesson 03-05.
  • Joining a stream with a static table (the profiles) makes it possible to compare recent behaviour with usual behaviour.
  • The final conditions are rules; in the real system, these features also feed a classification model that returns a probability of fraud.

An important nuance: for the millisecond response to the card terminal, the bank does not use micro-batches but an event-at-a-time streaming engine and key lookups in a NoSQL database (lesson 02-03). The snippet above corresponds to the alerts layer for the analysts, which tolerates seconds.

Results (fictitious)

  • Detection time: from 40 minutes to less than a second.
  • Undetected fraud: reduced by around 35%.
  • Legitimate transactions blocked: cut by half.

Lessons learnt and risks

  • The imbalance is extreme: fewer than one fraudulent transaction in every thousand. Accuracy is useless as a metric; you work with precision and recall, as in lesson 04-03, and the threshold is set with the business: how much fraud is accepted in exchange for not bothering legitimate customers.
  • Labels arrive late. The model is always trained on fraud from weeks ago, and fraudsters change tactics. You have to monitor degradation and retrain frequently.
  • Consistency between training and serving. Features must be calculated in the same way in batch (when training) and in streaming (when deciding). If they differ, the model fails in production without anyone knowing why.
  • Risks: blocking legitimate customers, automated decisions that must be explainable, and strict financial regulation. Blocking rules and models must be validated by those responsible for risk and regulatory compliance.

Healthcare: readmission prediction and bed management

Context and problem

The Montealto Hospital Network brings together six hospitals with 2,400 beds. Two related problems: a significant percentage of patients are readmitted within 30 days of discharge, which is bad for them and costly for the system; and bed occupancy is planned with spreadsheets, with some wards overflowing while others have room.

Warning. Health data is a specially protected category under data protection regulations. A project like this requires, before a single line of code is written, a legal basis for the processing, an impact assessment, pseudonymisation and access control measures, and review by the data protection officer, the ethics committee and those responsible for regulatory compliance. In addition, a model that influences clinical decisions must be validated by healthcare professionals. Nothing that follows replaces that review; privacy and ethics are developed in Module 7.

Data

  • Hospital episodes: admission, discharge, department, coded diagnoses, procedures.
  • Laboratory results and vital signs.
  • Demographic data and medical history.
  • Bed movements in near real time.

The volume is modest: about 180,000 episodes a year. The difficulty is not the size, but the variety (dozens of different systems, free text in the reports) and the sensitivity.

Architecture

flowchart LR
    HIS[Electronic health record] --> B[(Bronze:<br>restricted access)]
    LAB[Laboratory] --> B
    ADM[Admissions and beds] --> B
    B -->|pseudonymisation| P[(Silver:<br>no direct identifiers)]
    P --> O[(Gold: features per episode)]
    O --> M[Readmission<br>risk model]
    O --> PR[Occupancy forecast]
    M --> C[Clinical dashboard:<br>list of at-risk patients]
    PR --> G[Bed management dashboard]

The distinctive piece is the step from bronze to silver: direct identifiers (name, medical record number) are replaced by a pseudonym, and only a very small group can access bronze. Everything is batch: the decision (planning discharge and follow-up) is made once a day.

Technical solution

The first step, and the most delicate, is to build the label: was this episode followed by a readmission within 30 days? It is solved with a window function:

-- Illustrative: not runnable with the course data
SELECT
    episode_id,
    patient_pseudonym,
    discharge_date,
    LEAD(admission_date) OVER (PARTITION BY patient_pseudonym
                               ORDER BY admission_date) AS next_admission,
    CASE WHEN DATEDIFF(
             LEAD(admission_date) OVER (PARTITION BY patient_pseudonym
                                        ORDER BY admission_date),
             discharge_date) <= 30
         THEN 1 ELSE 0 END AS readmission_30d
FROM silver.episodes
WHERE discharge_date <= DATE_SUB(CURRENT_DATE(), 30)
  • LEAD (lesson 03-03) brings, for each episode, the date of the same patient's next admission.
  • The final WHERE excludes discharges in the last 30 days: it is not yet known whether there will be a readmission. Including them would label as "no readmission" patients whose period has not yet expired.

The features (age, number of previous admissions, length of stay, diagnoses) must use only information available at the time of discharge. This is the data leakage from lesson 04-03: including, for example, appointments after discharge would give a model that is brilliant on paper and useless on the ward.

Results (fictitious)

  • The 20% of patients with the highest risk score account for 55% of readmissions: this allows post-discharge telephone follow-up to be directed at those who need it most.
  • Error in the seven-day occupancy forecast below 5%, with fewer last-minute transfers.

Lessons learnt and risks

  • The model prioritises; it does not decide. Its output is a ranked list for the nursing staff, who decide whom to call. In high-risk contexts, human oversight is not optional.
  • A simple, explainable model (a logistic regression with a dozen features) was adopted more readily than a more accurate one that nobody understood.
  • Data quality was 70% of the work: diagnoses coded differently in each hospital, discharges recorded days late.
  • Risks: re-identification of patients from pseudonymised data, bias (a model trained on data from one hospital may perform worse in another, or for certain groups of patients; lesson 07-04) and overconfidence in the score.

Retail: personalisation and recommendations

Context and problem

Arcadia is a fashion chain with 300 physical shops, an online shop and 8 million members in its loyalty programme. The website showed everyone the same featured products. The goal: personalised recommendations on the website, in the app and in emails, to increase conversion and basket value.

Data

  • Browsing events on the website and the app: about 150 million a day.
  • Receipts from the physical shops, identified by the membership card.
  • Catalogue, with attributes (size, colour, season) and stock per shop.

Architecture

flowchart LR
    W[Website and app] --> K[Kafka]
    T[Shop receipts] -->|daily load| L[(Lakehouse)]
    K --> L
    L -->|nightly training| R[Recommendation model]
    R -->|10 recommendations<br>per member| N[(NoSQL key-value)]
    K -->|current session| F[Streaming: latest products viewed]
    F --> N
    N -->|millisecond reads| W

The recommendations are precomputed in batches every night and stored by key in a NoSQL database, from which the website reads them in milliseconds. A small streaming layer adjusts them according to what the customer is looking at right now.

Technical solution

The model is collaborative filtering with ALS, the algorithm that lesson 04-03 introduced conceptually: it learns, from which customers interact with which products, to predict what each one will be interested in.

# Illustrative: not runnable with the course data
from pyspark.ml.recommendation import ALS

# Implicit preference: a purchase weighs more than an add to cart, and that more than a view
interactions = (
    spark.read.table("silver.events")
    .withColumn("weight", F.when(F.col("event_type") == "purchase", 5.0)
                           .when(F.col("event_type") == "add_to_cart", 3.0)
                           .otherwise(1.0))
    .groupBy("member_id", "product_id")
    .agg(F.sum("weight").alias("interest"))
)

als = ALS(userCol="member_id", itemCol="product_id", ratingCol="interest",
          implicitPrefs=True, rank=50, regParam=0.1,
          coldStartStrategy="drop", seed=42)
model = als.fit(interactions)

recommendations = model.recommendForAllUsers(10)       # 10 products per member
recommendations.write.mode("overwrite").parquet("s3://arcadia-lake/gold/recommendations")
  • There are no explicit ratings (stars), so interest is inferred from behaviour: that is what implicitPrefs=True indicates.
  • rank is the number of factors with which the model describes each member and each product.
  • recommendForAllUsers(10) generates the table that is then loaded into the NoSQL database.

Comparison with NovaMarket

Arcadia NovaMarket
Catalogue Tens of thousands of items that change every season 200 products in the practice environment, stable
Interest signal Website, app and physical shop, linked by the membership card Web events only; 30% of sessions are anonymous
Purchase frequency High: several purchases a year Low: electronics and home, average order value of €1,677
Typical recommendation "Goes well with…", similar products Accessories and add-ons; "bought together" (graph, lesson 02-03)

The comparison explains why NovaMarket cannot copy the solution. With infrequent purchases there are few interactions per customer, and collaborative filtering learns little; recommendations based on the product being viewed work better. And there is a limitation you already know: in your data, purchase events do not match orders, so the model could not even be evaluated properly.

Results (fictitious)

  • Conversion of sessions with personalised recommendations 8% higher, measured with an A/B test (lesson 04-05).
  • 12% of online revenue comes from recommended products.

Lessons learnt and risks

  • Cold start: new customers and products have no history. A fallback is needed (best sellers, similarity by attributes).
  • Stock rules. Recommending a product that is out of stock in the customer's size is worse than recommending nothing: the model needs a business filter afterwards.
  • Measure with experiments, not with the model's metric: what matters is whether people buy more.
  • Risks: recommendations that the customer perceives as intrusive, filter bubbles that reduce the variety of what is shown, and the use of personal data for profiling, which requires a legal basis and transparency (lesson 07-02).

Telecommunications: churn prediction and network analysis

Context and problem

Telvia is an operator with 5 million mobile lines. Every month it loses around 1.8% of its customers, and acquiring a new one costs several times more than retaining an existing one. Marketing launched retention offers blindly. At the same time, the network team suspected that many cancellations were due to coverage problems that nobody linked to the customers.

Data

  • Network usage records (calls, data sessions): about 2 billion a day. It is, by far, the largest volume in this lesson.
  • Quality measurements per cell tower: dropped calls, speed, congestion.
  • Billing, contracts, minimum terms.
  • Customer service contacts and complaints.

Architecture

flowchart LR
    RED[Network equipment] --> K[Kafka]
    K --> B[(Bronze:<br>usage records)]
    CRM[CRM and billing] -->|CDC| B
    B --> P[(Silver)]
    P --> O1[(Gold: quality per tower and hour)]
    P --> O2[(Gold: monthly features per customer)]
    O1 --> NOC[Network operations centre dashboard]
    O1 --> O2
    O2 --> M[Churn model]
    M --> CAMP[Retention campaigns]

The key idea lies in the arrow from O1 to O2: the network quality each customer has experienced becomes a feature of the churn model. Two worlds that did not talk to each other, brought together in the lake.

Technical solution

With 2 billion records a day you do not train on the detail: you aggregate first to one row per customer and month. It is the rule from lesson 04-01, "aggregate big, analyse small", on another scale.

# Illustrative: not runnable with the course data
usage = spark.read.table("silver.usage_records").where(F.col("month") == "2026-05")
quality = spark.read.table("gold.tower_quality_hourly")

features = (
    usage.join(quality, ["tower_id", "hour"])
    .groupBy("customer_id")
    .agg(F.sum("megabytes").alias("megabytes_month"),
         F.countDistinct("day").alias("days_with_usage"),
         F.avg("dropped_call_rate").alias("drops_experienced"),
         F.avg((F.col("congestion") > 0.9).cast("int")).alias("pct_time_congested"))
)

data = (
    features
    .join(spark.read.table("gold.contracts"), "customer_id")       # tenure, tariff, minimum term
    .join(spark.read.table("gold.monthly_complaints"), "customer_id", "left")
    .join(spark.read.table("gold.churn_next_month"), "customer_id", "left")   # the label
    .fillna({"num_complaints": 0, "churned": 0})
)
  • The first join links each usage record with the quality of the tower at that hour; aggregating it by customer gives the quality that this customer experienced, not the network average.
  • The left joins and fillna treat anyone without complaints or who did not cancel as a zero, not as missing data.
  • The label is churn in the following month: the features are from May and the label from June. Using features from the same month as the cancellation would, once again, be data leakage.

A MLlib classifier is trained on data with a Pipeline, as you did in predict_purchase.py.

Results (fictitious)

  • The 10% of customers with the highest predicted risk account for 40% of actual cancellations.
  • Monthly churn rate from 1.8% to 1.5% in the segments where action was taken.
  • Unexpected finding: a group of congested cell towers explained a cluster of cancellations in two cities. The solution was not an offer, but expanding the network.

Lessons learnt and risks

  • Predicting is not retaining. The model says who will leave, not what to do. They had to measure with control groups whether the offer changed the decision; for some customers, the call reminded them that they wanted to leave.
  • Cost matters at this scale. Keeping the detail of the usage records for years was the largest item on the bill: a 90-day retention period was set for the detail, with aggregates for the rest (lesson 05-03).
  • The value lay in combining domains, not in the algorithm.
  • Risks: usage and location records are particularly sensitive personal data, with their own sector-specific regulation. Their use for analysis must be reviewed by the regulatory compliance department.

Manufacturing and energy: predictive maintenance with sensors

Context and problem

Cierzo Wind operates 400 wind turbines spread across 22 wind farms. A failure in a turbine's gearbox means weeks of downtime, a heavy-duty crane and a considerable loss of production. Maintenance was preventive, by calendar: everything was inspected every six months, whether it was needed or not, and even so failures came as a surprise. The goal is predictive maintenance: intervene when the data announces a failure, and only then.

Data

  • Each turbine has about 300 sensors (temperatures, vibrations, oil pressure, power, wind speed) that emit one reading per second: about 10 billion readings a day.
  • Work orders and failure history: barely a few dozen serious failures a year.
  • Weather forecasts.

It is the opposite case to the hospital: an enormous volume of very simple data, and very few examples of what you want to predict.

Architecture

flowchart LR
    S[Sensors] --> E[Wind farm gateway:<br>filtering and aggregation]
    E -->|per-minute aggregates| K[Kafka]
    K --> F[Streaming: comparison<br>with normal behaviour]
    F --> AL[Alerts to maintenance]
    K --> L[(Data lake:<br>time series)]
    OT[Work orders] --> L
    L -->|batch| MOD[Normal behaviour models]
    MOD --> F
    AL --> PLAN[Planning of interventions]

A new piece appears: edge processing. The wind farms are in remote locations with limited connections, so a device at each farm filters and aggregates the readings before sending them. What reaches the centre is per-minute summaries, not every reading.

Technical solution

As there are hardly any failures with which to train a classifier, the approach is turned around: the normal behaviour of each turbine is modelled, and an alert is raised when it deviates from it. This is anomaly detection.

# Illustrative: not runnable with the course data
readings = read_from_kafka("sensors_per_minute")        # turbine_id, sensor, value, event_time

averages = (
    readings
    .withWatermark("event_time", "10 minutes")
    .groupBy(F.window("event_time", "1 hour", "10 minutes"), "turbine_id", "sensor")
    .agg(F.avg("value").alias("hourly_avg"))
)

# Normal behaviour of each sensor on each turbine, recalculated in batch
normal = spark.read.parquet("s3://cierzo-lake/gold/normal_behaviour")

anomalies = (
    averages.join(normal, ["turbine_id", "sensor"])
    .withColumn("deviation",
                (F.col("hourly_avg") - F.col("normal_mean")) / F.col("normal_std"))
    .where(F.abs("deviation") > 4)
)
  • The one-hour moving average smooths out the noise of individual readings.
  • The deviation expresses how many standard deviations the value is away from what is usual for that sensor on that turbine. A bearing at 70 °C may be normal on one machine and alarming on another.
  • The threshold of 4 is deliberately high, so as not to flood the maintenance team with warnings.

In the real system, "normal" also depends on the conditions: the expected bearing temperature is predicted from the power, the wind and the outside temperature, and an alert is raised when the actual temperature moves away from the predicted one.

Results (fictitious)

  • Two out of every three serious failures anticipated more than three weeks in advance: enough time to book the crane and choose a day with little wind.
  • Unplanned downtime reduced by 30%.

Lessons learnt and risks

  • False alarms kill the project. If technicians climb a turbine three times for nothing, they stop paying attention. It is the alert fatigue from lesson 05-01, with an 80-metre ladder.
  • Quality starts at the sensor. Miscalibrated or disconnected sensors produce data that looks like machine anomalies. You have to distinguish "the turbine is failing" from "the sensor is failing".
  • The technicians' knowledge was essential for interpreting which combination of signals precedes each type of failure.
  • Order of arrival is not guaranteed: with unstable connections, data from a wind farm may arrive hours late. Event time and the watermark stop being theory.
  • Risks: the security of connected industrial systems (lesson 07-01) and the temptation to cut back preventive maintenance before the system has proven its reliability.

The same ingredients serve a transport company: vehicle positions are the readings, and route optimisation or delay forecasting, the use case.

Cross-sector comparison

Finance Healthcare Retail Telecommunications Manufacturing and energy
Case Card fraud Readmissions and beds Recommendations Churn and network Predictive maintenance
Volume 12 million transactions/day 180,000 episodes/year 150 million events/day 2 billion records/day 10 billion readings/day
Dominant V Velocity Variety (and sensitivity) Volume and variety Volume Volume and velocity
Latency Milliseconds One day Hours (computation) and milliseconds (serving) One month (churn); minutes (network) Minutes
Processing Streaming + batch Batch Batch + some streaming Batch + streaming Edge + streaming + batch
Technologies Kafka, streaming engine, NoSQL key-value, lake Lake with pseudonymisation, SQL, simple model Kafka, lakehouse, MLlib (ALS), NoSQL Kafka, CDC, lake, MLlib Gateways, Kafka, streaming, time series
Type of analytics Predictive (classification) Predictive and descriptive Predictive (recommendation) Predictive and diagnostic Predictive (anomalies)
Main risk Blocking legitimate customers; regulation Privacy; clinical decisions Perceived intrusiveness; privacy Privacy of usage and location False alarms; industrial security

NovaMarket resembles the retail case above all, and borrows its fraud detection from the finance case. By volume, with 40 million events a day, it sits at the lower end of the group: well above the hospital and well below the operator or the wind energy company.

Recurring patterns

Beneath the differences, the five cases share decisions you already know:

  1. Latency is set by the business decision, not by the available technology. Milliseconds to authorise a payment; a day to plan a discharge. Only the bank needed streaming on the critical path (lessons 01-04 and 03-05).
  2. Batch and streaming coexist. Even the most immediate system trains its models and recalculates its profiles in batches. Nobody chose "real time only".
  3. The zoned lake appears in all of them. Raw data kept, a clean layer and a consumption layer (lesson 02-04). In the hospital, the boundary between bronze and silver is also a privacy boundary.
  4. You aggregate before analysing. No model is trained on billions of raw records: first, one row per customer, per episode or per turbine and hour (lessons 04-01 and 04-02).
  5. Data quality decides the result more than the algorithm does. Badly coded diagnoses, miscalibrated sensors, late labels. In all of them, most of the effort went into preparing data (lesson 05-02).
  6. Value comes from combining sources. Network with customers, shop with website, sensors with work orders. It is the argument for a common platform rather than silos.
  7. Interesting events are rare. Fraud, churn, failures, readmissions: always a minority. Imbalance and the choice of metrics are everyday matters (lesson 04-03).
  8. Data leakage lurks in every label. At the hospital, the operator and the bank, care had to be taken that the features did not contain information from after the moment of prediction.
  9. The model recommends; someone decides. And the greater the harm of a mistake, the more human oversight and explainability are required.
  10. Measure with the business. A/B tests and control groups, not the model's technical metric (lesson 04-05).
  11. Cost and retention are designed. The telecoms operator and the wind energy company cannot keep all the detail forever (lesson 05-03).
  12. Regulation and privacy shape the architecture from day one, not at the end (lesson 05-01 and Module 7).

Common Mistakes and Tips

  • Copying the architecture of a much larger company. What solves a problem with 2 billion records a day is a burden with 40 million. Copy the reasoning, not the diagram.
  • Believing the figures in published cases. They are the successes, told by someone who wants to sell something or to show off. Ask about the cost, the time and the failed attempts.
  • Starting with the flashiest case. Real time and advanced models look impressive; but the first project should be the one with the best ratio of value to difficulty, which is almost always batch.
  • Ignoring what happens when the system fails. A false positive does not cost the same in a recommendation as in a card block or on a hospital ward.
  • Leaving regulatory compliance until the end. In healthcare, finance and telecommunications it can force you to redo the architecture.
  • Confusing prediction with action. Knowing who is going to cancel does not retain anyone. The project ends when a decision changes.
  • Tip: when you study a case from another sector, translate it to your own. "What is my equivalent of a failure?" often uncovers use cases nobody had considered.

Exercises

Exercise 1: choosing the architecture

For each situation, state the latency required, whether you would use batch, streaming or both, and the main risk:

  1. An insurer wants to detect potentially fraudulent accident claims before paying out the compensation, which is processed in about ten days.
  2. A delivery company wants to notify customers if their parcel is going to arrive late, at least 30 minutes in advance.
  3. A supermarket chain wants to decide every night how much fresh produce to send to each shop.

Exercise 2: spotting data leakage

A Telvia team trains the churn model with these features, all calculated over the month in which the customer did or did not cancel: megabytes consumed, number of complaints, tenure, whether they called the cancellations department and whether they requested to port their number. The model achieves an AUC of 0.99. Explain what is happening, which features are the problem and how it is corrected.

Exercise 3: a case for NovaMarket

Write, with the structure of this lesson and in brief format (two or three lines per section), the case study for NovaMarket's demand forecasting, one of its four use cases: context and problem, data, architecture (in one sentence), technical solution, how the result would be measured and risks. Bear in mind what you know about the course data.

Solutions

Exercise 1

  1. Latency of hours or a day: batch. The decision takes ten days; a score calculated every night arrives with time to spare. Risk: delaying or denying legitimate compensation because of an automated decision; the score should be used to prioritise review by a person, and the processing must be validated by regulatory compliance.
  2. Minutes: streaming, with vehicle positions in near real time, plus batch to train the model that estimates delivery times. Risk: false alarms that annoy the customer, or notifications that arrive late because data is delayed when the vehicle loses coverage.
  3. One day: batch. The decision is made at night. Risk: the asymmetric cost of error (produce that is thrown away versus an empty shelf) and sudden changes in demand due to public holidays or the weather, which the model must know about.

Only the second one needs streaming. That is the usual proportion.

Exercise 2

It is data leakage. "Called the cancellations department" and "requested to port their number" are consequences of the decision to leave, not early signs: they happen when the customer has already decided, and they will not be available at the moment you want to predict. The complaints and the usage in the month of cancellation itself are also contaminated, because a customer who is leaving stops using the line. An AUC of 0.99 on a problem of human behaviour is, on its own, a warning sign, like the 0.976 in lesson 04-03.

Correction: separate the features from the label in time. Features calculated with data up to the end of month M; label, cancellation during month M+1 (or M+2, if the retention campaign needs a month's margin to act). And remove any feature that is part of the cancellation process itself.

Exercise 3

A possible answer:

  • Context and problem. NovaMarket buys from its suppliers weeks in advance. If it buys too much, it ties up money in the warehouse; if it buys too little, it loses sales. Today the decision is based on the purchasing team's intuition.
  • Data. fact_sales with dim_product and dim_date: units sold per product and day. Calendar of campaigns and public holidays; prices; stock.
  • Architecture. Batch: the purchasing decision is weekly; a weekly process reads from gold, trains and writes a gold/demand_forecast table.
  • Technical solution. Aggregate to units per category and week (per product there would be very little data: 200 products and 50,000 lines in six months); calendar features and sales from previous weeks with lag; a regression model, always compared with a simple baseline ("the same as last week").
  • Measurement. Forecast error compared with the baseline and, in the business, stock-outs and inventory value before and after.
  • Risks and limitations. With six months of history, annual seasonality (Christmas, sales) cannot be learnt, and the course data does not contain it; returns distort real demand; a model trained in a normal period fails when faced with a campaign it has not seen.

Common mistake: proposing real-time streaming "so that the forecast is always up to date". The decision is weekly: updating the forecast every second does not change a single purchase and multiplies the cost.

Conclusion

You have gone through five sectors with the same template. In finance, fraud requires deciding within milliseconds with a streaming engine supported by profiles calculated in batch. In healthcare, the volume is small and the difficulty lies in the variety, the sensitivity of the data and clinical oversight. In retail, recommendations are precomputed every night and served from a NoSQL database. In telecommunications, the volume forces aggregation and the value appears when the network is combined with the customers. In manufacturing and energy, billions of readings and very few failures lead to modelling what is normal in order to detect what is anomalous. The differences in latency, volume and risk are enormous; the patterns, however, are repeated: the business decision sets the latency, batch and streaming coexist, the lake is organised in zones, data quality weighs more than the algorithm, and privacy and cost are designed in from the start.

Reading other people's cases teaches you to recognise patterns, but the craft is acquired by solving your own. You have a complete lake, a set of scripts you have written yourself, quality rules and criteria for judging the result. In the next lesson, Practical Projects, you are going to use all of this without step-by-step guidance: you will receive a brief from Irene as a professional would receive it, you will build a sentiment analysis of product reviews and you will design a near-real-time dashboard. It is time to check that what you have learnt over five modules works when nobody tells you what the next command is.

© Copyright 2026. All rights reserved