The ML and data science landscape

View Source on GitHub

A smart meter logs 10,000 electricity readings per customer per year. Some customers are bypassing their meters. You are asked to build a system that catches them.

The natural first move is to write rules. If monthly consumption drops by 40%, flag the account. If recorded usage is consistently lower than the neighbourhood average, flag it. If the meter reading pattern changes after a maintenance visit, flag it.

You build the rules and test them. They catch some cases but miss many others. A family going on holiday looks like a thief. A household cutting back in winter looks suspicious. You add exceptions, then exceptions to the exceptions. Every new rule surfaces a case it handles incorrectly. And as theft patterns evolve, your rules become outdated before you finish writing them.

You cannot solve this by writing more rules. The combinations of factors are too numerous, too variable, and too context-dependent for any human to enumerate.

This is the problem that machine learning was built to solve. In traditional programming, you write the rules and the computer applies them. In machine learning, you reverse the flow: you provide data and labeled examples of the outcome you want, and the computer finds the rules. When the rules are too complex to write by hand, that reversal is the right move.

The chapters that follow are the path from “I can write Python” to “I can build and ship that system.” This introduction gives you the map before you start walking.

Key Concept: when rules fail, patterns can be learned

Traditional programming: you write the rules, the computer applies them to data.
Machine learning: you provide labeled examples, the computer learns the rules from data.

When the rules are too complex, too numerous, or simply unknown until you look at the data, switching from writing rules to learning from examples is the right approach. The energy theft problem above is one instance of this structure. Fraud detection, medical diagnosis, demand forecasting, and language translation are others.

1. Precise terms for a noisy conversation

Artificial Intelligence (AI) is what headlines use. It covers everything from a chess engine to a text generator to a recommendation algorithm. Reaching for AI as the description of what you are building leads to poor decisions in practice: it overstates complexity, makes it harder to reason about data requirements, and obscures what the system can and cannot do.

This book uses four terms precisely.

Artificial Intelligence (AI) is the broad goal of making machines behave intelligently. It is the umbrella: a chess engine, a fraud detector, a voice assistant, and a self-driving car all qualify.

Machine Learning (ML) is one approach to AI: a system that learns patterns from data instead of following rules written by hand. The energy theft detector above is ML. So is a model that forecasts next month’s demand or classifies a chest X-ray.

Data Science is the broader practice that uses ML as one of its primary tools. It combines statistics, visualisation, and domain knowledge to extract insight and support decisions from data. A data scientist builds the model but also frames the problem, validates the results, and communicates findings to people who make decisions.

MLOps is the engineering discipline that puts models into production and keeps them working. A model that runs on a laptop is not useful until it runs reliably on a server, updates when the data changes, and produces results fast enough to act on. MLOps is the work that makes that happen.

These four terms describe what this book actually teaches. The diagram below shows how they relate to each other.

Nested ovals showing AI as the outermost boundary, Machine Learning inside it, Deep Learning inside ML. Data Science overlaps with the ML oval. An MLOps box sits below, connected by an arrow, labelled: takes models to production.

The relationship between AI, ML, Data Science, and MLOps. ML sits inside the AI hierarchy; Data Science uses ML as one of its tools; MLOps is the engineering layer below both that takes trained models to production.

Common Mistake: using AI when you mean ML

“We are using AI to solve this” almost always means “we trained an ML model on labeled examples.” Using the broader term makes it harder to reason about data requirements, model limitations, and what to do when the system fails. Name the specific technique: logistic regression, gradient-boosted trees, a fine-tuned language model. Precision here is not pedantry: it is how you avoid building the wrong thing.

2. The tool stack

ML systems are not built with a single tool. They are built in layers. Python is the language every layer is written in. On top of it sit the libraries that handle data, then the libraries that build models, then the infrastructure that deploys them.

Four stacked layers labelled: Foundation (Python), Data Tools (NumPy, Pandas, Polars, Matplotlib), Modelling (scikit-learn, XGBoost, LightGBM, PyTorch), Deploy and Monitor (MLflow, FastAPI, Docker).

The data science and ML tool stack: four layers from Python at the foundation to deployment at the top. Each layer depends on the one below it.

The Modelling layer includes classical ML (scikit-learn, XGBoost, LightGBM) and deep learning (PyTorch). Both sit on the same data foundation and plug into the same deployment infrastructure above them. Which you reach for depends on the problem: structured tabular data favours gradient boosting; images, text, and sequences favour deep learning.

You do not need to know all of this before you start. You need to know it exists, so that the time you spend on each layer has a clear purpose. Chapter 1 is the foundation. Everything above it follows.

The destination of this stack is not a trained model. It is a working product: a system that runs reliably, updates when the world changes, and produces decisions that create measurable value. Every chapter moves toward that goal, not just toward a metric on a validation set.

3. Why you learn Python before ML

A biology student who wants to study cells spends their first lab session learning the microscope. Not because microscopes are interesting in themselves. Because understanding the tool is what makes the science possible.

Python, NumPy, and Pandas are that microscope. You are not learning them as prerequisites to survive before the interesting part. You are learning them because without them you cannot build anything that works, debug anything that breaks, or trust any result the model produces.

The chapters ahead move in the same order the tool stack does: foundation first, then data, then models, then production.

4. Your learning path

NoteWhere this book takes you
Part Chapters What you build What it unlocks
Python foundations 1–8 Variables, control flow, functions, classes, the standard library, NumPy, Pandas, Matplotlib You can write Python and work with structured data
Data tools 9–16 Pandas operations, reshaping, time series, Polars, Great Tables You can load, clean, transform, and present real datasets
ML and MLOps 17+ Model training, evaluation, experiment tracking, deployment, monitoring You can build, ship, and maintain ML systems

The energy theft system from the opening of this chapter belongs in the ML landscape section. The data pipeline that feeds it belongs in the data analysis section. The Python that holds all of it together starts in Chapter 1.


Next: Chapter 1: Python core: the language every other layer is built on.