Part I — Foundations & Data Preprocessing

Chapter 1 · Machine Learning Foundations

What machine learning actually is, how it relates to statistics and AI, the taxonomy of learning problems, the end-to-end workflow of an ML project, and the Python toolchain this course uses — before a single model is trained.

📖 Chapter 1 of 33 ⏱ ~60 min read Core Stable Volatile 📝 Quiz · 10 MCQs

🎯 Learning Objectives

1. What Is Machine Learning?

In traditional programming, a human writes the rules and the computer applies them to data to produce answers. In machine learning, the direction reverses: the computer derives the rules from data. Arthur Samuel's classic definition calls it the field of study that gives computers the ability to learn without being explicitly programmed; Tom Mitchell's more formal version says a program learns from experience E with respect to task T and performance measure P if its performance at T, measured by P, improves with E.

Traditional programming:  Rules + Data → Answers
Machine learning:  Data + Answers → Rules
📝
Note: Machine learning is not a replacement for statistics — it is built on it. Regression, probability and hypothesis testing are the mathematical backbone of every algorithm in this course. Chapter 2 gives you exactly the statistical vocabulary the rest of the book assumes.

2. The Taxonomy of Machine Learning

Nearly every method in this course falls into one of three families, distinguished by what kind of "experience" the algorithm learns from.

Machine Learning Supervised Unsupervised Reinforcement Regression · Classification learns from labelled data Clustering · Association rules Dim. reduction · learns structure Multi-armed bandits learns from rewards Parts II–III · Ch 4–18 Parts IV–V, IX · Ch 19–22, 28–30 Part VI · Ch 23–24
Figure 1.1 — The three families of machine learning and where this course treats each.
Family Learns from Typical question Chapters
Supervised Input–output pairs (labels) "Predict this value / class" 4–18
Unsupervised Unlabelled inputs "What structure hides in this data?" 19–22, 28–30
Reinforcement Rewards from interaction "Which action maximises long-term reward?" 23–24
💡
Pro Tip: When you meet a new problem, first ask: do I have labels? A known target variable (price, class, rating) means supervised learning. No target means unsupervised. Feedback arriving over time means reinforcement learning. Every algorithm choice flows from this one question.

3. The ML Workflow

A professional ML project is a pipeline of decisions, not a single model.fit() call. The workflow below is the map for the whole course — each stage gets dedicated chapters.

  1. Frame the question — business objective → measurable ML task
  2. Collect & explore the data — Chapter 2's statistics
  3. Preprocess — missing values, encoding, scaling, splitting (Chapter 3)
  4. Train candidate models — Parts II–IX
  5. Evaluate honestly — Chapters 10, 18, 31
  6. Tune & select — Chapter 31
  7. Deploy & monitor — Chapter 33's capstone perspective
🌎
Real World: Practitioners spend far more time on stages 2–3 than on training models. Data quality, not algorithm choice, is the most common reason projects fail. That is why this course devotes Part I entirely to data.

4. Overfitting & Underfitting — First Pass

The single most important idea in machine learning: a model is judged by its performance on new, unseen data, not on the data it was trained on. A model that memorises its training set — overfitting — scores perfectly in training and fails in production. A model too simple to capture the underlying pattern — underfitting — fails everywhere. This tradeoff gets a formal treatment (bias–variance decomposition) in Chapter 6, and every chapter afterwards refers back to it.

⚠
Warning: Never evaluate a model on its training data. The test set is touched exactly once, at the end. Violating this — "data leakage" — is the most common honest mistake in ML, and it silently inflates every metric you report.
📋 Stable content — Reviewed: August 2026

5. Setting Up Your Python Environment

Two installation paths work for this course. Pick one — the code is identical either way.

Option A — Anaconda (recommended for a local setup)

# Install Anaconda or Miniconda, then create the course environment
conda create -n mlaz python=3.11
conda activate mlaz

# Core stack used throughout the course
pip install numpy pandas matplotlib scikit-learn

# Used from Part VII onwards
pip install nltk tensorflow xgboost

Listing 1.1 — Creating an isolated environment for the course.

Option B — Google Colab (zero installation)

Colab runs Jupyter notebooks in the browser with the entire stack pre-installed, including GPU access for Part VIII (Deep Learning). Every code listing in this book runs in Colab unchanged.

⚠ Volatile content — Reviewed: August 2026 · Next review: November 2026

6. The Python ML Ecosystem

The core libraries this course relies on — and their current standing.

Library Role in this course First used
numpyNumeric arrays, vectorised mathCh 3
pandasDataFrames, loading CSVsCh 3
matplotlibPlotting and visual checksCh 3
scikit-learnAll classical ML models & metricsCh 3
statsmodelsStatistical summaries (R², p-values)Ch 5
nltkText processingCh 25
tensorflow / KerasNeural networks (ANN, CNN)Ch 26
xgboostGradient boostingCh 32

The library landscape evolves quickly; the concepts in this book do not. Sections like this one carry a volatility badge and are reviewed quarterly.

🛠 Hands-On: Your First ML SessionBeginner

Before training any real model, verify your environment and take your first look at data the way an ML practitioner does. You will load a dataset, inspect its shape and summary statistics, and confirm the library versions — establishing the workflow every later chapter builds on.

Steps

  1. Create a new Jupyter notebook (or Colab notebook) named ch01_first_session.
  2. Import numpy, pandas and sklearn, and print their versions.
  3. Load the Chapter 3 dataset Data.csv with pandas and print its shape.
  4. Call dataset.describe() and write one sentence about what it tells you.
View Solution / Walkthrough
import numpy as np
import pandas as pd
import sklearn

print('numpy     :', np.__version__)
print('pandas    :', pd.__version__)
print('sklearn   :', sklearn.__version__)

dataset = pd.read_csv('Data.csv')
print('Shape     :', dataset.shape)        # (rows, columns)
print(dataset.describe())                  # count / mean / std / min / max ...

What you should see: 10 rows and 4 columns; the summary table shows per-column counts (spot missing values when a count falls below 10), means and spreads of the numeric columns. Note that describe() silently drops non-numeric columns — one of many small traps pandas sets for beginners, formalised in Chapter 3.

🎯 Key Takeaways

1

ML flips programming: instead of writing rules, the machine infers rules from data plus answers.

2

The three families — supervised, unsupervised, reinforcement — are decided by what the algorithm learns from, not by the algorithm itself.

3

Models are judged on unseen data. Overfitting (memorising) and underfitting (oversimplifying) bracket every model you will ever build.

4

The workflow — question, data, preprocess, train, evaluate, tune, deploy — is the map of this whole course.

5

Most project effort goes into data, not models: Part I exists because data quality decides project success.

Test Your Understanding

10 questions covering concepts, assumptions and interpretation from this chapter. Choose one answer per question, then check your answers.

Q1.Which task is a supervised learning problem?

Q2.Classifying emails as "spam" or "not spam" is an example of:

Q3.A grocery chain analyses thousands of unlabelled receipts to find products bought together. This is:

Q4.Overfitting is best described as a model that:

Q5.Which dataset split should be used for the final, unbiased performance estimate?

Q6.Which library is the standard toolkit for classical machine learning in Python?

Q7.In Mitchell's definition, a program "learns" if its performance at task T, measured by P:

Q8.Reinforcement learning algorithms improve by:

Q9.A model performs poorly on the training set AND the test set. This model is:

Q10.Which ordering reflects the ML workflow taught in this course?