Session 1 - AI Systems and ML Pipeline

AI Systems and ML Pipeline

Christian Cabrera Jojoa

Assistant Research Professor

Department of Computer Science and Technology

University of Cambridge

chc79@cam.ac.uk

Session 1 - AI Systems and ML Pipeline

Course Structure

Session 1 - AI Systems and ML Pipeline

Course Structure

  • Remote sessions combining theory and practice
  • AI systems and ML pipeline, linear models and perceptron, neural networks, transformers, and large language models
  • Content will be published weekly
  • You can ask questions at any moment
  • Participation is key
  • You will have (small) individual work during each session
  • Contact by email: chc79@cam.ac.uk
Session 1 - AI Systems and ML Pipeline

The AI Narrative

Session 1 - AI Systems and ML Pipeline

The AI Narrative

The Economist
The economics of superintelligence - The Economist (26th July - 8th August 2025)

"AI will be capable of generating novel insights next year." (Altman, 2025)


"Self-improving AI will create a super intelligence." (Musk, 2025)


"When I look at the data, I see many trend lines up to 2027." (Clark, 2025)


"There is a 10-20% chance that the technology will end in human extinction." (Hinton, 2025)


"Our relationship with future AI systems is that we are going to be their boss." (LeCun, 2025)

Session 1 - AI Systems and ML Pipeline

The AI Narrative

"Within ten years a digital computer will be the world's chess champion." (Simon & Newell, 1958)


"Machines will be capable, within twenty years, of doing any work a man can do." (Simon, 1965)


"Within a generation... the problem of creating 'artificial intelligence' will substantially be solved." (Minsky, 1967)


"In from three to eight years we will have a machine with the general intelligence of an average human being." (Minsky, 1970)

"AI will be capable of generating novel insights next year." (Altman, 2025)


"Self-improving AI will create a super intelligence." (Musk, 2025)


"When I look at the data, I see many trend lines up to 2027." (Clark, 2025)


"There is a 10-20% chance that the technology will end in human extinction." (Hinton, 2025)


"Our relationship with future AI systems is that we are going to be their boss." (LeCun, 2025)

Session 1 - AI Systems and ML Pipeline

The AI Narrative

You'll own slaves by 1965 (1957)
You'll own "slaves" by 1965 (1957) - https://medium.com/@theo/do-we-need-robot-rights-in-the-age-of-artificial-intelligence-690b9951bae0

"AI will be capable of generating novel insights next year." (Altman, 2025)


"Self-improving AI will create a super intelligence." (Musk, 2025)


"When I look at the data, I see many trend lines up to 2027." (Clark, 2025)


"There is a 10-20% chance that the technology will end in human extinction." (Hinton, 2025)


"Our relationship with future AI systems is that we are going to be their boss." (LeCun, 2025)

Session 1 - AI Systems and ML Pipeline

The AI Narrative

AI just could be a smart buy (1987)
AI just could be a smart buy (1987)
The Economist
The economics of superintelligence - The Economist (26th July - 8th August 2025)
Session 1 - AI Systems and ML Pipeline

AI History - Machine Learning Age (2001 - present)

1940 1950 1960 1970 1980 1990 2000 2010 2020 2030 First AI Winter (1974-1980) Second AI Winter (1987-1994) Big Data (2000-2012) Artificial Neuron (McCulloch & Pitts, 1943) Information Theory (Shannon, 1948) Cybernetics (Wiener, 1948) Updating Rule (Hebbian, 1949) Computing Machinery and Intelligence (Turing, 1950) SNARC (Minsky, 1951) AI Term (Dartmouth Workshop, 1956) GPS (Newell & Simon, 1957) Advice Taker (McCarthy, 1958) Back-Propagation (Kelley, 1960) Perceptrons (Rosenblatt, 1962) ELIZA (MIT, 1966) ALPAC Report (USA, 1966) The DENDRAL (Buchanan, 1969) Perceptrons Book (Minsky & Papert, 1969) PROLOG (1972) MYCIN (Stanford, 1972) Lighthill Report (UK, 1973) FRAMES (1975) Hopfield net (1982) R1 (McDermott, 1982) Parallel Distributed Processing (Rumelhart & McClelland, 1986) Bayesian Networks (Pearls, 1988) Reinforcement Learning (Sutton, 1988) Image Recognition (LeCun et al., 1990) Deep Blue beats Kasparov (IBM, 1997) Deep Learning (Hinton, 2006) Watson wins Jeopardy (2011) AlexNet (Krizhevsky, 2012) GANs (Goodfellow, 2014) AlphaGo beats Lee Sedol (DeepMind, 2016) Transformer (Vaswani, 2017) AlphaFold (DeepMind, 2018) GPT-1 (OpenAI, 2020) BERT (Google, 2019) Chinchilla (DeepMind, 2022) ChatGPT (OpenAI, 2022) LLaMA (Meta AI, 2023) Claude 2 (Anthropic, 2023) phi-3 (Microsoft, 2024) Gemini 1.5 (Google DeepMind, 2024) Qwen3 (Alibaba, 2025) R1 (DeepSeek) 2025)
Session 1 - AI Systems and ML Pipeline

The AI Narrative

Perception
Session 1 - AI Systems and ML Pipeline

The AI Narrative

"We should stop training radiologists now. It’s just completely obvious that within five years, deep learning is going to do better than radiologists." (Hinton, 2016)

Geoffrey Hinton
NOBEL Prizes Ceremony 2024: Arthur Petron, CC BY-SA 4.0 , via Wikimedia Commons
Session 1 - AI Systems and ML Pipeline

The AI Narrative

"We should stop training radiologists now. It’s just completely obvious that within five years, deep learning is going to do better than radiologists." (Hinton, 2016)

Radiology Crisis
Radiology Crisis - Independent: https://www.independent.co.uk/news/health/cancer-delays-nhs-staff-shortages-b2561385.html
Session 1 - AI Systems and ML Pipeline

The AI Narrative

The freshest wave of the narrative is Agentic AI: autonomous agents, tool use, and orchestration. The pattern matches earlier hype: bold claims, compressed timelines, a rush to product, and ignoring previous communities like the Multi-Agent Systems (MAS) one.


The same structure is taking shape around quantum computing: early narratives mix real progress with expectations to capture investment.

Session 1 - AI Systems and ML Pipeline

The AI Narrative

Critical Thinking
Critical Thinking (Designed by freepik.com)

"It seems to me what is called for is an exquisite balance between two conflicting needs: the most skeptical scrutiny of all hypotheses that are served up to us and at the same time a great openness to new ideas. Obviously those two modes of thought are in some tension. But if you are able to exercise only one of these modes, whichever one it is, you're in deep trouble. (The Burden of Skepticism, Sagan, 1987)

Session 1 - AI Systems and ML Pipeline

The AI Narrative

Big tech companies investing in each other

Big tech companies have a direct economic interest in sustaining the narrative. They create value bubbles by investing in each other, inflating expectations and market valuations.


The hype cycle is not only an intellectual phenomenon, it is also an economic one.

Session 1 - AI Systems and ML Pipeline

The AI Narrative

Single Model
ML System?
https://xkcd.com/1838/, CC BY-NC 2.5 , via XKCD
Session 1 - AI Systems and ML Pipeline

The Technocentric Problem

Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

AI Puzzle
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
AI Puzzle
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
ML System?
https://xkcd.com/1838/, CC BY-NC 2.5 , via XKCD
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
Learning Model Accuracy
Model v1 88%
Model v2 90%
Model v3 98%
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
Learning Model Accuracy
Model v1 88%
Model v2 90%
Model v3 98%
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
Learning Model Accuracy
Model v1 88%
Model v2 90%
Model v3 98%

Does Model v3 satisfy users' requirements?

Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model
Learning Model Accuracy
Model v1 88%
Model v2 90%
Model v3 98%

Does Model v3 satisfy users' requirements?

For example:

  • Users require accurate and fast responses
  • The project budget is limited
  • The system must be user-friendly
  • Users with disabilities must be prioritised
  • ...
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model

Threat to AI applications and promises


  • Mundane applications for problems we did not know we had
  • Disregard for social and environmental implications
  • Unrealistic expectations and hype
  • Exclusion of diverse perspectives and voices
  • Unsustainable technologies
  • Increased inequality and digital divide
  • Security and privacy concerns
  • ...
Session 1 - AI Systems and ML Pipeline

The "Technocentric" View

Single Model

"Grok referenced the debunked conspiracy theory of “white genocide” in South Africa in reply to unrelated prompts, such as questions about baseball or humorous requests to talk like a pirate. " (May, 2025)


"ChatGPT suggested a dangerous route to tourists hiking in the mountains in Poland and resulted in the hikers having to be rescued." (January, 2025)


"Steve Talley, a financial adviser in Denver, Colorado, was wrongfully arrested twice for bank robberies he did not commit, based on flawed facial recognition technology and questionable identification procedures." (September, 2014)

Learn more at the AIAAIC Repository

Session 1 - AI Systems and ML Pipeline

Systems Engineering Approach

Session 1 - AI Systems and ML Pipeline

The Problem First

The systems engineering approach is better equipped than the ML community to facilitate the adoption of this technology by prioritising the problems and their context before any other aspects.

Session 1 - AI Systems and ML Pipeline

The Systems Engineering Approach

Session 1 - AI Systems and ML Pipeline

The Systems Engineering Approach

Systems Thinking
Process Model
Session 1 - AI Systems and ML Pipeline

The Systems Engineering Approach

Systems Thinking
Process Model
Systems views: Defining the problem from different perspectives
Agility systems: Flexible architectures and solutions
Systems dynamics: Models that show systems evolution
Session 1 - AI Systems and ML Pipeline

The Systems Engineering Approach

Systems Thinking
Process Model
Systems views: Defining the problem from different perspectives
Top-down analysis: Divide and conquer approach
Agility systems: Flexible architectures and solutions
Variant creation: Assessing solution alternatives
Systems dynamics: Models that show systems evolution
Problem solving cycle: Following a methodology
Session 1 - AI Systems and ML Pipeline

Machine Learning Pipeline

Session 1 - AI Systems and ML Pipeline

Machine Learning Pipeline

Data Assess Pipeline
Session 1 - AI Systems and ML Pipeline

ML Pipeline vs ML-based System

Data Assess Pipeline
ML-based System
Session 1 - AI Systems and ML Pipeline

Data Science Process

Session 1 - AI Systems and ML Pipeline

The Data Science Process

Session 1 - AI Systems and ML Pipeline

The Data Science Process

Data Science Process
Session 1 - AI Systems and ML Pipeline

The Data Science Process

Data Science Process
Session 1 - AI Systems and ML Pipeline

The Data Science Process

Data Science Process
Session 1 - AI Systems and ML Pipeline

Data Access

Session 1 - AI Systems and ML Pipeline

Data Access

Data Science Process

We start with access: getting the data in front of us before we judge it or model it.

Session 1 - AI Systems and ML Pipeline

Data Access

Does the data even exist?

Session 1 - AI Systems and ML Pipeline

Data Access

Primary Data Collection

  • Questionnaires and interviews
  • Surveys and case studies
  • Field instrumentation and sensors
  • Experimental method

No, it does not exist!

Session 1 - AI Systems and ML Pipeline

Data Access

Primary Data Collection

  • Questionnaires and interviews
  • Surveys and case studies
  • Field instrumentation and sensors
  • Experimental method
  • Expensive data collection processes
  • Particular methodologies
  • None fits all needs
Session 1 - AI Systems and ML Pipeline

Data Access

Secondary Data Collection

  • Government records and census data
  • Public sector and agency catalogs
  • Published literature and reports
  • Open datasets and public APIs

Yes, it does exist!

Session 1 - AI Systems and ML Pipeline

Data Access

Secondary Data Collection

  • Government records and census data
  • Public sector and agency catalogs
  • Published literature and reports
  • Open datasets and public APIs
  • Validity and reliability concerns
  • Outdated data
  • Relevancy issue
Session 1 - AI Systems and ML Pipeline

Data Access

Crash Map Location
Crash Map Kampala was an initiative by Michael T. Smith and Bagonza Jimmy Owa Kinyonyi to map the location, date and severity of vehicle accidents across the city of Kampala. Original storage location for the data was in police logbooks.

Crash Map Kampala

  • Road traffic accidents are a leading cause of death for the young in many contexts
  • Data is difficult to access and made impossible any analysis of the problem
Session 1 - AI Systems and ML Pipeline

Data Access

The dataset creation is a critical process that cannot be skipped. We can assume datasets exist, but they will likely enable toy projects not relevant for our society

Crash Map Kampala
Crash Map Kampala was an initiative by Michael T. Smith and Bagonza Jimmy Owa Kinyonyi to map the location, date and severity of vehicle accidents across the city of Kampala. Original storage location for the data was in police logbooks.
Session 1 - AI Systems and ML Pipeline

Data Access

Accessing data via APIs

  • APIs are interfaces that let different systems talk to each other
  • Servers expose them, clients consume them
  • The query itself is an access decision: what we ask for is what we get
import requests

url = "<url_of_the_dataset>"
response = requests.get(url, timeout=60)
response.raise_for_status()
Session 1 - AI Systems and ML Pipeline

Data Access

The USGS earthquake catalog

  • Published by the United States Geological Survey
  • Secondary source: somebody else decided what to record and how
  • The FDSN event API returns a CSV for a region, a time window, and a minimum magnitude
  • Those three choices define the dataset we will assess today
base = "https://earthquake.usgs.gov/fdsnws/event/1/query"
parameters = {
    "format": "csv",
    "starttime": "2024-01-01",
    "endtime": "2025-01-01",
    "minmagnitude": "4.5",
}
query = "&".join(f"{k}={v}" for k, v in parameters.items())
url = f"{base}?{query}"
Session 1 - AI Systems and ML Pipeline

Data Assess

Session 1 - AI Systems and ML Pipeline

Data Assess

Data Science Process

With the data in hand we move to assess: deciding whether it is fit for the question.

Session 1 - AI Systems and ML Pipeline

Data Assess

After collecting the data (i.e., data access), we need to perform a data assessment process to understand the data, identify and mitigate data quality issues, uncover patterns, and gain insights.

Session 1 - AI Systems and ML Pipeline

Data Assess

Data Assess Pipeline

Four families of methods sit inside this stage: cleaning, preprocessing, augmentation, and feature engineering.

Session 1 - AI Systems and ML Pipeline

Data Cleaning

Process of detecting and correcting (or removing) corrupt or inaccurate records.

Session 1 - AI Systems and ML Pipeline

Data Cleaning

Missing Values

Missing data points in the dataset

  • Data collection errors
  • System failures
  • Information not available
  • Data entry mistakes
Missing Values
Session 1 - AI Systems and ML Pipeline

Data Cleaning

Missing Values

  • Deletion: remove rows or columns with missing values
  • Imputation: fill missing values with estimated values
  • Advanced techniques: use machine learning models to predict missing values

A missing value is not always empty. It can also be a placeholder that looks like data.

features = ['Pclass', 'SibSp', 'Parch', 'Fare']
known = titanic.dropna(subset=['Age'])
imputer = LinearRegression()
imputer.fit(known[features], known['Age'])

unknown = titanic['Age'].isnull()
titanic.loc[unknown, 'Age'] = imputer.predict(
    titanic[unknown][features]
)
Session 1 - AI Systems and ML Pipeline

Data Cleaning

Outliers

Outliers

Data points that significantly deviate from the rest of the data: measurement errors, data entry mistakes, system malfunctions, or rare but valid observations

  • Capping: limit values to a range
  • Log transformation: reduce the impact of extreme values
Session 1 - AI Systems and ML Pipeline

Data Cleaning

Outliers
def cap_outliers(df, column):
    Q1 = df[column].quantile(0.25)
    Q3 = df[column].quantile(0.75)
    IQR = Q3 - Q1
    lower = Q1 - 1.5 * IQR
    upper = Q3 + 1.5 * IQR
    df[column + '_capped'] = df[column].clip(
        lower=lower, upper=upper
    )
    return df
Session 1 - AI Systems and ML Pipeline

Data Preprocessing

Process of transforming raw data into a format suitable for machine learning while ensuring data quality and consistency.

Session 1 - AI Systems and ML Pipeline

Data Preprocessing

Feature Scaling

Transforming numerical features to a common scale

  • All features contribute equally to the model
  • Algorithms converge faster
  • Features with larger scales do not dominate the model

Standardisation (Z-score) centres data around 0 with unit variance

: data point
: dataset mean
: dataset standard deviation

Session 1 - AI Systems and ML Pipeline

Data Preprocessing

Min-Max scaling maps data to a fixed range [0,1]

: the minimum value of the feature
: the maximum value of the feature

scaler = StandardScaler()
cols = [col + '_st' for col in num_feat]
data[cols] = scaler.fit_transform(data[num_feat])

scaler = MinMaxScaler()
cols = [col + '_minmax' for col in num_feat]
data[cols] = scaler.fit_transform(data[num_feat])
Session 1 - AI Systems and ML Pipeline

Data Augmentation

Process of increasing the size and diversity of our datasets.

More diversity makes models more robust

  • Adding controlled noise
  • Random rotations
Data Augmentation
Session 1 - AI Systems and ML Pipeline

Data Augmentation

More size improves generalisation

  • Interpolating between existing data points
  • Applying domain-specific transformations
  • Generating synthetic data using GANs

SMOTE interpolates between a point and its k-nearest neighbours

def numerical_smote(data, k=5):
    aug_data = []
    for i in range(len(data)):
        uniq = np.unique(data[data != data[i]])
        dists = np.abs(uniq - data[i])
        k_neigs = uniq[np.argsort(dists)[:k]]
        for neig in k_neigs:
            step = np.random.random() * (neig - data[i])
            aug_data.append(data[i] + step)
    return np.array(aug_data)
Session 1 - AI Systems and ML Pipeline

Feature Engineering

Process of creating, transforming, and selecting features in our data, combining domain knowledge and creativity.

Session 1 - AI Systems and ML Pipeline

Feature Engineering

Creating new features can capture important patterns or relations in the data

  • Extracting information from existing features
  • Combining existing features
  • Adding domain knowledge rules
data['AgeGroup'] = pd.cut(
    data['Age'],
    bins=[0, 12, 18, 35, 60],
    labels=['Child',
            'Teenager',
            'Young Adult',
            'Adult'],
)
Session 1 - AI Systems and ML Pipeline

Feature Engineering

Correlation Matrix

Selecting the most important features reduces dimensionality, prevents overfitting, improves interpretability, and reduces training time

corr_matrix = data.corr()
sns.heatmap(corr_matrix, annot=True, center=0)
plt.show()
Session 1 - AI Systems and ML Pipeline

Feature Engineering

Feature Importance

Decision trees rank features by information gain

Principal Component Analysis

PCA turns correlated features into uncorrelated components that capture most of the variance

Session 1 - AI Systems and ML Pipeline

Data Quality

Every method above answers the same question: is the data fit for a purpose?

Data quality is multi-dimensional

  • Accuracy does the value match the event?
  • Completeness are the fields we need present?
  • Uniqueness is each event listed once?
  • Consistency do units and scales agree?
  • Timeliness is the record current enough for the decision?
  • Validity does the value obey the declared format?
Data Quality
Session 1 - AI Systems and ML Pipeline

Data Quality

Data Usability

Poor data quality can lead to:

  • Inaccurate predictions
  • Biased results
  • Over-trust in a table that is not fit
  • Intellectual debt
Session 1 - AI Systems and ML Pipeline

Data Quality

For a post-earthquake review, ask of each row:

  • Do we know where it was, and with what uncertainty?
  • Do we know how large it was, and on which scale?
  • What risk remains if we still train a first model?

The answer depends on the decision, not on the table alone. The same rows can be fit for one question and unfit for another.

Session 1 - AI Systems and ML Pipeline

Data Address

Session 1 - AI Systems and ML Pipeline

Data Address

Data Science Process

Only now do we reach address: using the data we trust to answer the question we started from.

Session 1 - AI Systems and ML Pipeline

Data Address

After assessing the data (i.e., data assess), we need to use the data to address the problem in question. This process includes implementing a Machine Learning algorithm that creates a Machine Learning model.

Session 1 - AI Systems and ML Pipeline

Data Address

A Machine Learning algorithm is a set of instructions that are used to train a machine learning model. It defines how the model learns from data and makes predictions or decisions. Linear regression, decision trees, and neural networks are examples of machine learning algorithms.

ML Algorithm
Session 1 - AI Systems and ML Pipeline

Data Address

A Machine Learning model is a program that is trained on a dataset and used to make predictions or decisions. The goal is to create a trained model that can generalise well to new, unseen data.

ML Model
Session 1 - AI Systems and ML Pipeline

Data Address

A Machine Learning algorithm uses the training process that goes from a specific set of observations to a general rule (i.e., induction). This process adjusts the model internal parameters to minimise prediction errors. In a linear regression model, the algorithm adjusts the slope and the intercept.

Training Process
Session 1 - AI Systems and ML Pipeline

Data Address

In classification problems, the prediction is one of a finite set of values (e.g., safe / unsafe). In regression problems, the model's output is a number.

Prediction errors are quantified by a loss function that tells the algorithm how far the prediction is from the target. Mean Squared Error is the common choice for regression.

ML Model
Session 1 - AI Systems and ML Pipeline

Data Address

Our address step today

  • A regression problem: predict the horizontal location error from the station coverage gap
  • One feature, one target, a straight line
  • It is a first fit to practise the step, not an inspection tool
  • The rows the model never saw are part of the result
from sklearn.linear_model import LinearRegression

usable = catalog[["gap", "horizontalError"]].dropna()
X = usable[["gap"]].to_numpy()
y = usable["horizontalError"].to_numpy()
model = LinearRegression().fit(X, y)
Session 1 - AI Systems and ML Pipeline

Conclusions

Machine Learning Pipeline
Data Science Process
Session 1 - AI Systems and ML Pipeline

Conclusions

Overview

  • AI narrative and the technocentric problem
  • Systems engineering and problem first
  • ML pipeline and data science methodology
  • Access, assess, and address in practice

Next Time

  • Linear and logistic models
  • The perceptron
  • Activation function, loss function, and back propagation
Session 1 - AI Systems and ML Pipeline

Many Thanks!

chc79@cam.ac.uk

_script: true

This script will only execute in HTML slides

_script: true