Loading lesson...
Loading lesson...
The AI Foundations stage builds the vocabulary and the working habits that the Applied and Practice stages spend their time applying. It sets out what artificial intelligence actually is and how it differs from ordinary software, why the quality of the training data puts a ceiling on the quality of the system, what supervised, unsupervised and reinforcement learning each require and each produce, how a loss function turns a wrong answer into a number and how gradients turn that number into a weight change, why the split between training, validation and test data is the only thing standing between you and a flattering lie, which metric to read when accuracy is misleading, which architecture family matches which shape of data, what fairness means once you notice that its definitions conflict, and how to interrogate an AI system that somebody else built and is trying to sell you.
One argument runs through all eight modules. An AI system learns its behaviour from data rather than having it written down, so every question you would normally ask about code has to be asked about data and evidence instead. That single inversion is why data quality outranks algorithm choice, why a held-out test set matters more than a clever architecture, why a headline accuracy figure can hide a system that catches none of the cases you built it for, and why fairness cannot be delegated to the model. The machinery in the stage exists to serve that habit: the pipeline stages tell you where errors and leakage enter, the loss function tells you what the model is actually being asked to optimise, the confusion matrix tells you which mistakes it is making, and the responsible AI vocabulary tells you who those mistakes fall on.
The sections follow the stage's teaching order, so you can read straight through to rebuild the stage in your head, or jump to the concept you need. Each section links back to its module for the full treatment, including the worked examples, the interactive tools and the primary sources.
John McCarthy coined the term artificial intelligence for the 1956 Dartmouth Workshop and defined it as the science and engineering of making intelligent machines. The definition is deliberately broad, and its breadth is the source of most of the confusion around the word. Module 1 replaces the single word with three nested categories. Artificial intelligence is the outermost: any system performing tasks associated with intelligence, which includes rule-based expert systems that contain no learning whatsoever. Machine learning sits inside it and covers systems that learn patterns from data instead of following written rules. Deep learning sits inside machine learning and covers neural networks with many layers. Large language models are one application of the innermost category, not a synonym for the outermost one.
Virtually everything in production is narrow AI: a system that performs one task, often very well, and cannot transfer that ability elsewhere. A chess engine cannot write a letter and a spam filter cannot drive. Artificial general intelligence, meaning a system that could perform any intellectual task a person can, does not exist and has no timeline with scientific consensus behind it. Whenever this course says AI without qualifying it, it means narrow AI.
The dividing line that actually matters in practice is not a category label but the direction the rules travel. Traditional software takes rules from a programmer and applies them to data. Machine learning takes data and an algorithm and produces the rules. Three consequences follow directly and they shape everything later in the stage. Behaviour is learned rather than specified, so you cannot read the source to find out why a decision was made; the reasoning sits in millions of numerical weights. Quality depends on data as much as on code, which reverses the usual instinct to fix things by writing better code. And systems decay: the world changes but a trained model does not update itself, so a fraud model trained on one year of attacks will quietly miss the next year's, which is what model drift means. Note also that the model is only one component. The system around it is what takes the action and carries the accountability, and the diagram below draws that boundary explicitly.
Both lanes end at an output arrow entering the same system boundary, and only that boundary, holding policy, guardrails, review and audit, emits the action, so swapping a written rule for a learned model moves none of the accountability.
A learned model's output is one input to the decision. The surrounding system, with its policy, guardrails, and human review, is what makes the decision and carries the accountability.
In ordinary software a bug produces a wrong answer you can trace. In machine learning a problem in the data produces a wrong answer that looks right, because the model has faithfully learned whatever was in front of it. That asymmetry is why Module 2 treats data as the first-order concern and the choice of algorithm as second order, and it is the argument behind the data-centric position that improving the data usually pays better than improving the model.
Five problem families account for most failures. Bias means the training data does not represent the population the system will serve, so historical decisions get relearned as ground truth. Noise means random variation that carries no signal, from sensor error, typing mistakes or inconsistent measurement. Missing values force a choice between dropping records, imputing values and using a model that handles gaps natively, and the right choice depends entirely on why the values are missing rather than on how many are. Label errors mean the supposed correct answer is wrong, and they are not rare: Northcutt, Athalye and Mueller found label errors in the test sets of ten widely used vision, language and audio benchmarks, averaging at least 3.3 per cent across the ten and reaching at least 6 per cent of the ImageNet validation set. Class imbalance means one category swamps the other, which is what lets a fraud model that never predicts fraud report an excellent score.
The pipeline runs from collection through cleaning, exploration, feature engineering and finally splitting, and each stage can add problems as well as remove them. Cleaning is where most of the project time goes. Feature engineering is where domain knowledge enters the model: a raw timestamp is hard to learn from, but the day of the week and a weekend flag are not; a full address is high cardinality, but a postcode district paired with a published deprivation score carries the signal. The trap that runs through the whole pipeline is leakage, meaning information that the model would not have at prediction time slipping into its inputs, and the figure below marks the checkpoints where it enters. One last correction: more data is not automatically better. A carefully curated small dataset regularly beats a large noisy one, and adding a million irrelevant records helps nothing.
Each card pairs what the step produces with the leakage signature that fails it, and every arrow between them is labelled only if clean, so a check skipped at one card leaves every later card validating data that is already contaminated.
Data leakage is caught at four checkpoints between raw records and a model that is ready to train. Each step has a clear success signature and a clear failure signature; missing a check at one step contaminates everything downstream.
Supervised learning is the mode behind most production AI. The training data contains inputs and the correct answers, and the model learns a mapping from one to the other that holds up on examples it has never seen. It splits into classification, where the output is a discrete category such as spam or not spam, and regression, where the output is a continuous number such as a price or a temperature. Recommendation, fraud detection, medical imaging and translation are all supervised problems.
Unsupervised learning works when there are no labels at all and the task is to find structure. Clustering groups similar records without being told what the groups should be. Dimensionality reduction compresses many variables into a few while preserving the relationships that matter, which is what makes a complex dataset visualisable. Anomaly detection picks out the records that do not fit the normal pattern. The catch is evaluation: with no correct answers to compare against, success has to be judged by whether the discovered structure is useful downstream, which is a softer and more arguable standard.
Reinforcement learning is different in kind. An agent acts in an environment, observes a state, takes an action and receives a reward or a penalty, and what it learns is a policy: a strategy for choosing actions that maximises reward accumulated over time rather than accuracy on a fixed dataset. Self-play, where a system generates its own experience by competing against itself, is the classic illustration, and reinforcement learning from human feedback is how model outputs get aligned with human preference. The stage returns to reinforcement learning in depth later in the course. For now the practical move is the pivot question in the figure below: ask what feedback the training data can carry, and the mode follows from the answer rather than from preference.
Each lane states what it requires before it states what it learns, and the three connectors read labels exist, no labels and reward signal, so the mode is settled by the data already in hand and not by the algorithm chosen afterwards.
The learning mode is determined by the feedback available at training time, not by algorithm preference. Labels point to supervised, no labels point to unsupervised, and a delayed reward signal points to reinforcement learning.
A loss function turns a wrong prediction into a number, and training is the process of adjusting parameters to make that number smaller. Mean squared error is the common choice for regression: take the difference between predicted and actual, square it so that large errors count for more than small ones, and average across the examples. Cross-entropy is the common choice for classification: it measures how far the model's predicted probability distribution sits from the true one. The important point is not the formula but the consequence. The loss is where your priorities enter the model. A loss that punishes a missed diagnosis heavily produces a different system from one that punishes an unnecessary follow-up test equally, and neither is more correct in the abstract.
The split into training, validation and test data is what stops you deceiving yourself. The model learns from the training set, typically the largest share. The validation set is used during development to tune hyperparameters such as learning rate and model complexity and to detect overfitting; the model does not learn from it directly, but every decision about the model is influenced by it. The test set is used once, at the very end, to estimate performance on genuinely unseen data. Consult it repeatedly while adjusting the model and it quietly becomes a second validation set, at which point it can no longer give an unbiased estimate of anything.
Data leakage is the failure mode that undoes all of this, and its most common form is procedural rather than dramatic. Normalise the whole dataset before splitting it and the mean and standard deviation you computed include the test data, so test-set statistics have entered training. The correct order is to split first, compute the parameters on the training set alone, then apply those same parameters to validation and test. Overfitting is the condition all of this defends against: a model that memorises the training set rather than learning patterns that transfer. Its signature is unmistakable once you look for it, a training loss that keeps falling while the validation loss turns and starts rising, and the standard response is early stopping at the epoch where validation loss was lowest.
A single artificial neuron does three things. It multiplies each input by a weight and sums the results, which is how it expresses that some inputs matter more than others. It adds a bias term, which lets the decision boundary sit anywhere rather than being forced through the origin. And it passes the total through a non-linear activation function such as ReLU, which passes positive values through unchanged and flattens negatives to zero, or sigmoid, which squashes the output into the range zero to one. The non-linearity is not decorative. Without it, stacking a hundred layers computes exactly the same family of functions as one layer, because a composition of linear functions is itself linear. Depth only buys expressive power when something non-linear sits between the layers.
Neurons are arranged in an input layer that receives the raw features, one or more hidden layers, and an output layer that produces the prediction. Forward propagation is simply running data through that arrangement: each neuron computes its sum, bias and activation and hands the result on, until the output layer produces a prediction and the loss function measures how far off it was. The depth in deep learning refers to the count of hidden layers. Published layer counts for proprietary commercial models are not available, so treat any specific figure you see quoted for them as speculation.
Backpropagation answers the question the loss raises: which weights contributed to this error, and in which direction should each move? It computes the gradient of the loss with respect to each weight in the output layer, then uses the chain rule to carry those gradients backwards through every hidden layer, then updates each weight by a small step against its gradient. The update rule is worth memorising because it explains the sign conventions that trip people up: the new weight equals the old weight minus the learning rate multiplied by the gradient, so a negative gradient increases the weight. The learning rate is the hyperparameter that decides how big each step is. Too large and the updates overshoot the minimum and the loss diverges. Too small and training crawls and can settle in a poor local minimum. Adaptive optimisers such as Adam adjust the rate during training, but the value you start with still matters.
Weights move only when the cycle closes, never when the forward pass runs again: the gradient arrow drops from the loss into the backward row, and a dashed arrow returns to the same neuron card that the forward pass used.
Learning is a closed loop: a forward pass produces a prediction, the loss measures the gap to the target, and a backward gradient pass nudges the weights so the next pass is closer to the target (Rumelhart, Hinton, Williams, Nature 1986).
Every binary classifier produces exactly four kinds of outcome, and every metric in this stage is built from them. A true positive is a correct positive call. A true negative is a correct negative call. A false positive is a false alarm: the legitimate email routed to the spam folder. A false negative is a miss: the phishing message that reached the inbox. The confusion matrix is nothing more than a two by two table holding those four counts, and Module 5 is emphatic that you read the counts before you compute any ratio, because the counts tell you where the mistakes are and the ratios only tell you how many.
Accuracy is the proportion of all predictions that were correct, meaning true positives plus true negatives divided by the total. On balanced data it is a reasonable summary. On imbalanced data it is actively misleading, and the demonstration is a single line of arithmetic. Take a screening test for a condition present in one per cent of the population. A model that predicts no condition for every single patient scores ninety-nine per cent accuracy and catches nobody. Its recall for the class you built it to find is zero. Accuracy has told you the model is almost always right while concealing that it is useless.
Precision and recall separate what accuracy conflates. Precision is true positives divided by all positive predictions, and it answers how many of the things you flagged were real, so high precision means few false alarms. Recall, also called sensitivity, is true positives divided by all actual positives, and it answers how many of the real cases you caught, so high recall means few misses. The F1 score is their harmonic mean, which penalises a large gap between the two: an F1 of 0.9 means both are decent, whereas an F1 of 0.6 means at least one of them is poor. F1 is a sensible default when you have no reason to favour either, and it is the wrong choice the moment one type of error costs more than the other.
The 2 by 2 matrix of true and false positives and negatives derives all four metrics, and accuracy averages every cell into one number while precision, recall and F1 name which cell moved, so the metric has to be chosen against the failure you can afford.
Accuracy hides whether the failure mode is false positives or false negatives. The four derived metrics expose the cost shape so the right metric can be chosen for the domain.
Precision and recall pull against each other, and the thing that moves them is the decision threshold. Lower it and the model becomes more willing to call something positive, which catches more real cases and raises recall while also flagging more innocent ones and lowering precision. Raise it and the trade runs the other way. Which direction you want is a domain judgement rather than a technical one. Spam filtering leans towards precision, because a false positive means a job offer or a legal notice disappears into a folder nobody checks. Cancer screening leans towards recall, because a false negative means a patient with the disease is told they are well. Leaving the threshold at its default of 0.5 is not a neutral act; it is a decision made by not deciding, and the figure below shows what shifts when you move it deliberately.
The second failure this module addresses is a model that looks good on the data it was fitted to and falls apart elsewhere. Overfitting means the model has learned the noise and the accidents of the training set as though they were signal, so training performance is high and validation performance is not. Underfitting is the opposite condition, a model too simple to represent the pattern at all, and it shows as poor performance on both. The diagnostic is the same in each case: plot training loss and validation loss against training epochs and read the gap. When training loss keeps improving while validation loss turns upwards, the model has crossed into memorisation and the useful checkpoint is behind you.
The third correction is about how much a reported number is worth. A single train and test split is fragile, because which examples happened to land in the test set can flatter or punish the model by chance. In k-fold cross-validation the data is divided into k folds, commonly five or ten, the model is trained k times with a different fold held out each time, and the performance estimate is the average across the runs. That gives you two things a single split cannot: a mean and a spread. If performance swings widely across folds, the model is unstable or the dataset is too small, and that instability is exactly what one lucky split conceals. Treat any headline figure from a single split with scepticism, and report confidence intervals rather than a bare number.
Precision rises and recall falls across the same axis, and no threshold on it improves both. The centre card marks the optimum as something the team sets from domain cost, not a value the model can supply.
The decision threshold is a domain-cost choice, not a model property. Moving it left catches more positives at the cost of more false alarms; moving it right does the reverse.
A convolutional network exists because a fully connected network throws away everything spatial. Flatten an image into a list of numbers and the model has no idea that one pixel sits next to another. A convolutional layer instead slides a small filter, typically three by three or five by five, across the image, computing a dot product at each position and producing a feature map. Different filters respond to different things: edges, corners, textures, curves, and which filters are worth having is learned rather than designed. Pooling then shrinks the feature maps, most often by taking the maximum value in each small region, which cuts computation and buys a degree of translation invariance so that the same object is recognised wherever it sits in the frame. Stack these operations and a hierarchy emerges on its own: early layers respond to edges and colour gradients, middle layers to textures and parts, deep layers to whole objects. That hierarchy is why convolutional networks removed the need to hand-engineer visual features.
Sequences need a different assumption. A recurrent network processes one element at a time and carries a hidden state forward that summarises everything seen so far, which in principle lets it connect the start of a passage to its end. In practice a plain recurrent network cannot, because gradients are multiplied at every step during backpropagation through time and a factor below one shrinks them exponentially. After twenty or thirty steps the gradient is effectively zero and nothing early can influence anything late, which is the vanishing gradient problem. The Long Short-Term Memory network answers it with a cell state, a path running the length of the sequence that is modified additively rather than multiplicatively, and three gates that decide what to discard, what to store and what to expose at each step. Because the cell state is updated by addition, gradients survive along it, and dependencies across hundreds of steps become learnable.
The selection rule that follows is about matching assumptions to structure rather than reaching for whatever is newest. Spatial data such as images, scans and maps goes to convolutional networks, which assume local correlation. Ordered data such as text, audio and time series goes to recurrent and gated architectures, or to transformers when sequences are long, because these assume that order carries meaning. Well-structured tabular data goes to gradient-boosted trees, and this is the one that surprises people. Grinsztajn, Oyallon and Varoquaux benchmarked standard and novel deep learning methods against tree-based models such as XGBoost and random forests across a standard set of forty-five tabular datasets, and found that tree-based models remained state of the art on medium-sized data of roughly ten thousand samples even before accounting for their much greater speed. Using the wrong family forces the network to learn structure that the right family would have given you for nothing.
Every column reads down the same four rows, best fit data, mechanism, typical use, then the canonical paper: a sliding filter for CNN, a hidden state passed step by step for RNN, attention reaching every token at once for Transformer. Pick on the top row, the data shape.
Each architecture family has its data-shape sweet spot. Transformers generalise best for sequence tasks because attention reaches any token to any token directly.
Fairness in machine learning is not one property. It is a family of mathematical criteria, and several of them cannot hold at once. Demographic parity, also called statistical parity, requires that the proportion of positive predictions be the same across groups: if thirty per cent of one group is approved, thirty per cent of the other should be. Its appeal is obvious and so is its weakness, because it ignores differences in base rates and can therefore require approving applicants who are likely to default. Equalized odds instead requires that the true positive rate and the false positive rate be equal across groups, so that the model is equally right and equally wrong for everyone. Both are defensible. They are also, in general, incompatible.
That incompatibility is a theorem rather than an engineering shortcoming. Chouldechova's analysis of recidivism prediction instruments shows that the criteria cannot all be satisfied simultaneously when prevalence differs between groups, so a system that is calibrated within each group will have unequal error rates between them and vice versa. The ProPublica investigation of the COMPAS risk tool is what made this concrete for a general audience. Analysing risk scores for more than seven thousand people arrested in Broward County, Florida, in 2013 and 2014, it reported that the formula was particularly likely to falsely flag Black defendants as future criminals, wrongly labelling them that way at almost twice the rate of white defendants, while white defendants were mislabelled as low risk more often. The tool's developer maintained that predictive accuracy was comparable across groups. Both positions can be arithmetically true at once, which is precisely the point.
Because the model cannot resolve this for you, the discipline shifts to explanation, documentation and monitoring. LIME explains a single prediction by perturbing the input many times and fitting a simple interpretable model to the local region, which works on any model because it needs only inputs and outputs, at the cost of being local and somewhat unstable. SHAP attributes each feature a contribution derived from Shapley values in cooperative game theory, which gives it theoretical guarantees and both local and global explanations, at the cost of computation. A model card is the documentation layer: Mitchell and colleagues proposed short documents accompanying a trained model that give benchmarked evaluation across cultural, demographic and phenotypic groups and their intersections, together with intended use, the evaluation procedure and other relevant context. Around all of this sit disaggregated reporting, slice analysis on intersectional subgroups, counterfactual testing of protected attributes, and continuous monitoring, because a model that is fair at launch can stop being fair as the population moves. The surrounding structure is the NIST AI Risk Management Framework, organised around Govern, Map, Measure and Manage, which NIST states is intended for voluntary use. This stage does not teach it: the course returns to it in the Applied stage's governance and regulation module, and it is named here so you know what the vocabulary above is a part of.
Vertical arrows tie each of the six stages to the artefact above it and the harm below it, so a column where the artefact is missing is a stage whose named harm has nothing on record to answer it.
Responsibility is six checkpoints producing six written artefacts; each artefact prevents a specific harm at a specific lifecycle stage.
The capstone puts the whole stage to work on a single question: a supplier offers a trained system and reports good numbers, so what do you ask? Start with the data, because that is where transferability is decided. Was the model trained on a population like yours, or on a different case mix in a different country with different pathways? Do you collect the same inputs at the same frequency the model expects, because a model built on continuous readings behaves differently when fed spot checks every few hours? How was the target defined, since two reasonable definitions of the same outcome produce two different models with different characteristics? And how was missing data handled, given that a careless imputation can erase exactly the signal the system was meant to detect?
Then interrogate the evaluation. A threshold-independent summary such as the area under the ROC curve describes performance across all thresholds, but you will operate at one specific threshold, and the number that matters there is the positive predictive value: what fraction of the alerts are real. On rare events a strong summary score can coexist with a precision so low that people stop responding, and alert fatigue is a real operational harm rather than an inconvenience. Ask whether validation was temporal or a random split, because a random split over time-ordered data leaks patterns and inflates the result. Ask whether there are confidence intervals or cross-validated estimates, because a point estimate from one split carries no measure of its own reliability. Then ask for the same metrics broken down by subgroup, since an aggregate score can hide a large gap for the group most affected.
Finally check the architecture and the surrounding accountability. Ordered data needs an architecture that models order; a model that sees only the latest reading discards the trend, which is often the earliest signal of anything. Irregular sampling needs handling explicitly rather than being assumed away. Interpretability is not a luxury in a setting where a person has to decide whether to act on the output, and a slightly less accurate model whose reasoning can be inspected may be the better system. Then ask whether a model card exists, whether it names the uses the system is not for, and whether the people using it can override it and what happens when they do. A system nobody can override is unsafe; a system everybody overrides is expensive and pointless. The habit worth carrying out of this stage is the plainest one in it: validate on your own data before you trust anybody's headline number.
Every cell pairs a numbered question with the one artefact that answers it, and all four columns feed a pack card requiring all eight on file before sign-off, so strength in one column cannot cover a gap in another.
Every published claim about an AI system maps to a written artefact; without the artefact, the claim is not yet evidence.
Reporting a single accuracy figure and treating a high one as proof the system works.
Instead: Check the class distribution before you read any accuracy number. If one class dominates, compute precision and recall for the class you actually care about, and state what a model that always predicts the majority class would have scored. If that trivial model matches yours, accuracy has told you nothing.
Normalising, imputing or selecting features across the whole dataset and splitting afterwards.
Instead: Split first, always. Compute normalisation parameters, imputation values and feature selections on the training set alone, then apply those same fitted parameters to the validation and test sets. Any statistic computed over data that includes the test set has already contaminated the estimate.
Checking test-set performance during development and adjusting the model when it disappoints.
Instead: Tune against the validation set and touch the test set once, at the end, to produce the number you will report. If you have already consulted it several times, say so, and treat the figure as optimistic rather than unbiased. Cross-validation gives you a defensible estimate without spending the test set.
Reaching for a deep network on well-structured tabular data because it sounds more capable.
Instead: Match the architecture family to the structure of the data. On tabular problems, start with gradient-boosted trees and treat them as the baseline a neural network has to beat, since the published benchmark evidence has trees remaining state of the art on medium-sized tabular data and training far faster.
Treating fairness as a technical defect that a better algorithm or a post-processing step will fix.
Instead: Choose the fairness criterion first, in the open, with the people the decision falls on, and record why. The criteria are provably incompatible when base rates differ between groups, so every deployed model embodies a choice that somebody made. State which one you made rather than letting a default make it silently.
Leaving the classification threshold at its default and calling the result the model's performance.
Instead: Decide which error is more costly for this decision before you look at any output, then set the threshold to match and report precision and recall at that threshold. A default of 0.5 encodes the assumption that a false positive and a false negative cost the same, which is rarely true and never true by accident.
Responding to a biased model by collecting more of the same data.
Instead: Diagnose the bias before adding volume. If the training data underrepresents a population or encodes historical decisions you would not want to repeat, more of it makes the problem larger, not smaller. Audit representativeness and label quality first; volume only helps when the additional data is relevant, representative and correctly labelled.
Accepting a supplier's validation metrics as a prediction of how the system will perform for you.
Instead: Treat supplier metrics as evidence about the supplier's population, collection process and time period, and nothing more. Ask for the operating threshold, the temporal validation design, confidence intervals and subgroup breakdowns, then run a local validation on your own data before deployment rather than after.
The scenario practice that follows puts this stage under time pressure with incomplete information, which is how these questions actually arrive. You will be handed a proposal with a headline metric, a described dataset and a stated purpose, and asked which of the five data problem families is present, which metric the class distribution makes meaningless, whether the reported evaluation supports the claim being made, which architecture family the data shape calls for, and who bears the cost of the errors the system will make. Work it the way this summary works: read the raw counts before the percentages, ask what population the numbers were measured on, and say out loud which trade-off you are choosing rather than letting a default choose for you.