Difficulty: Intermediate to Advanced | Prerequisites: Basic graph terminology, introductory regression, W11 Part 1 notes (non-parametric tests, Bayesian methods)
This is the survey portion of the advanced models module. It introduces six distinct modelling families, each solving a different kind of problem: finding clusters in networks (graph communities), learning complex patterns from data (neural networks and deep learning), modelling strategic interactions (game theory), working with text (NLP), predicting time-to-event (survival models), and iteratively improving predictions (gradient boosting). None of these is covered in full depth here. The goal is conceptual literacy: know what each technique does, when to reach for it, and how it connects to the rest of the analytics toolkit. You should be comfortable with basic regression and optimisation concepts before diving in.
Graph community detection finds tightly connected subgroups in networks using algorithms like Louvain. Neural networks and deep learning learn patterns through layered, weighted connections. Game theory models decisions where competitors react to each other. NLP handles unstructured text data. Survival models predict when events will occur. Gradient boosting stacks models on top of each other, each one correcting the errors of the last.
Community (graph theory)
A subset of nodes in a graph that are densely connected to each other and sparsely connected to the rest of the network. Think of it as a clique or cluster within a larger social or information network.
Clique
A set of nodes where every node has an edge to every other node in the set. A fully connected subgraph.
Modularity
A score measuring how well a graph is partitioned into communities. High modularity means dense connections within communities and sparse connections between them.
Louvain algorithm
A greedy, heuristic algorithm for community detection that iteratively moves nodes between communities to maximise modularity, then collapses communities into super-nodes and repeats. In simple terms, it keeps shuffling nodes until no move improves the clustering score.
Neural network
A model inspired by biological neurons, with layers of interconnected nodes (input, hidden, output) where each connection carries a learned weight.
Deep learning
Neural networks with many hidden layers. The additional depth allows the model to learn more abstract and complex representations. Performs well on tasks like image recognition, speech recognition, and natural language processing.
Game theory
The study of strategic decision-making where the outcome depends on the choices of multiple participants who may react to each other.
Stable equilibrium (Nash equilibrium)
A state in which no player has an incentive to change their strategy, given what everyone else is doing. In simple terms, everyone is doing as well as they can, given the other players' choices.
Prisoner's dilemma
A situation where individually rational choices lead to a collectively worse outcome. Both players would be better off cooperating, but each has an incentive to defect.
Natural Language Processing (NLP)
The field of models that work with human language data: speech-to-text, entity recognition, sentiment analysis, text generation.
Survival model
A model that predicts the probability of an event occurring before a given time, based on predictor variables. Used in insurance, medicine, and equipment maintenance.
Cox Proportional Hazard Model
A survival model where the hazard (instantaneous event probability) is the product of a baseline hazard and an exponential function of predictor variables.
Gradient boosting
An ensemble method that builds models sequentially, each new model trained to predict the errors (negative gradient of the loss function) of the combined model so far. Think of it as stacking correction layers on top of a base prediction.
Tags: community detection, graph partitioning, modularity, Louvain, network analysis, clique, nodes, edges
In network data (social networks, disease transmission, supply chains), tightly connected subgroups matter. A community is a set of nodes with many internal connections and few external ones. Finding these communities automatically is the goal of community detection algorithms.
Graph basics:
Nodes (vertices): the entities (people, servers, cells)
Edges (arcs): the connections between them
Clique: a subset where every node connects to every other node in the subset
Modularity measures how good a partition is. For nodes i and j in the same community:
Modularity = (1 / 2W) * sum over (i, j in same community) of (a_ij - (w_i * w_j) / 2W)
where a_ij is the edge weight between i and j, w_i is the total weight of edges connected to node i, and W is the total weight of all edges. A higher modularity means the communities are well separated.
The Louvain algorithm:
Start with each node as its own community.
For each node, try moving it to an adjacent node's community. Make the move that produces the biggest modularity increase. Repeat until no move improves modularity.
Collapse each community into a single super-node (preserving total internal weight) and repeat step 2 on the coarsened graph.
The algorithm is heuristic, meaning it is not guaranteed to find the globally optimal partition. In practice, it finds very good solutions quickly and scales well to large networks.
Why it matters practically: in epidemiology, identifying communities helps target vaccination campaigns. In marketing, it reveals clusters of influence. In cybersecurity, unusual cross-community traffic can signal intrusion.
Tags: neural network, deep learning, input layer, hidden layer, output layer, weights, training, NLP, image recognition
Neural networks are modelled on biological neural systems. They consist of three types of layers:
Input layer: each neuron receives one piece of external input (a pixel value, a feature measurement).
Hidden layer(s): every input is passed to every neuron in the hidden layer. Each connection carries a weight. The hidden neurons compute weighted combinations of their inputs.
Output layer: the hidden layer's outputs are passed to the output layer, which produces the final prediction along with a confidence level. The weights are then updated based on how correct the output was.
Training neural networks requires large amounts of labelled data and significant computational resources. The process of adjusting weights based on error is called backpropagation.
Deep learning extends neural networks by adding many hidden layers (hence "deep"). Each additional layer can learn progressively more abstract features. In practice, deep learning has shown strong results in natural language processing, speech recognition, and image recognition. The trade-off is that deep models need even more training data and compute, and their internal logic is harder to interpret.
Tags: game theory, Nash equilibrium, stable equilibrium, prisoner's dilemma, cooperative game theory, pure strategy, mixed strategy, zero-sum, non-zero-sum, perfect information, imperfect information
Most models covered earlier in the course assume the system being modelled does not react to your decisions. Game theory drops that assumption: the other side adapts.
Where it applies:
Pricing: a competitor changes their price in response to yours
Tax policy: companies change spending behaviour in response to tax rules
Employee incentives: workers adjust effort in response to reward structures
Auctions: bidders adjust bids based on others' behaviour
Supply chains: parties negotiate cooperatively and competitively
When the situation involves both competition and cooperation, it is called Cooperative Game Theory.
The BP/Shell pricing example (prisoner's dilemma):
Shell and BP each choose between a high price (2.50) and a low price (2.00). If both go high, each earns 0.75d. If both go low, each earns 0.50d. If one goes low while the other stays high, the low-price firm earns 1.00d (capturing more customers) and the high-price firm earns nothing.
The stable equilibrium is both choosing 2.00, because neither can improve their position by changing unilaterally. Yet both would be better off at 2.50. This is the prisoner's dilemma: individual rationality leads to a collectively inferior outcome.
Strategy types:
Pure strategy: a single deterministic choice
Mixed strategy: randomising among choices according to set probabilities
In games like rock-paper-scissors, pure strategy loses and mixed strategy (randomising equally) is optimal.
Information levels:
Perfect information: all players know everything about the game state (chess)
Imperfect information: some information is hidden
Asymmetric information: one player knows more than another
Game types:
Zero-sum: one player's gain is exactly the other's loss (rock-paper-scissors)
Non-zero-sum: the total payoff varies depending on decisions (economics, pricing)
Tags: NLP, natural language processing, speech-to-text, named entity recognition, sentiment analysis, text generation, unstructured data
Most data covered in this course is structured (numeric or categorical). Language is neither. NLP is the umbrella term for models that process and interpret human language.
Core NLP tasks:
Speech-to-text: converting audio to written words
Named entity recognition and co-reference resolution: identifying people, places, and organisations in text, and linking pronouns to their referents
Determining meaning in context: the same word can mean different things depending on surrounding text
Sentiment analysis: classifying the emotional tone behind a word, sentence, or document
Text generation: given a concept or prompt, producing coherent language to convey it
At the introductory level, the key takeaway is that NLP transforms unstructured text into something a model can work with, and that deep learning has driven most of the recent progress in this area.
Tags: survival model, Cox proportional hazard, hazard function, baseline hazard, censored data, time-to-event, insurance, medicine
Survival models predict the probability that an event happens before a certain time. The "event" could be death, equipment failure, customer churn, insurance claim, or treatment response.
The Cox Proportional Hazard Model:
Given predictor variables x_1, ..., x_n and event time y, the hazard function is:
h(t) = h_0(t) * exp(beta_1 * x_1 + ... + beta_n * x_n)
h_0(t): the baseline hazard, the probability of the event at time t when all predictors are zero
h(t): the probability of the event at time t given the actual predictor values
exp(beta_j * x_j): the multiplicative effect of factor j on the hazard
beta_j: the coefficient for predictor j
beta_j = 0: x_j has no effect
beta_j > 0: higher x_j increases the hazard (event more likely)
beta_j < 0: higher x_j decreases the hazard (event less likely)
Censored data is a core challenge. You may not observe the event for every subject: some patients leave the study, some machines are still running at the end of the observation window. The data is incomplete, and survival models are specifically designed to handle this.
Applications: life insurance pricing, clinical trial analysis, predictive maintenance for machinery, modelling customer lifetime.
Tags: gradient boosting, ensemble method, residuals, loss function, negative gradient, XGBoost, model stacking
Gradient boosting takes a different approach to improving predictions. Instead of building one very good model, it builds a sequence of simple models, each one trained to correct the errors left by the previous ones.
How it works:
Start with a base model F(x) that predicts response variable y from predictors x.
Compute the errors (residuals): y - F(x).
Train a new model H(x) whose target is those residuals. If H perfectly captures the errors, then F + H is a perfect fit to the training data.
In practice, H is trained on the negative gradient of a loss function evaluated at F's predictions. For regression, this equals y - F(x). For classification or other tasks, the gradient takes a different form.
Add H to the combined model (with a scaling factor gamma) and repeat: each round trains a new correction model on the errors of the current combined model.
Stop when adding another model produces negligible improvement.
The final model is: F_k(x) = F_0(x) + gamma_0 * H_0(x) + gamma_1 * H_1(x) + ... + gamma_k * H_k(x)
This process is closely related to the iterative optimisation algorithms covered earlier in the course. The key difference is that instead of optimising parameters within a single model, you are optimising by adding entire models to the ensemble.
Modularity:
Modularity = \frac{1}{2W} \sum_{i,j \in \text{same community}} \left( a_{ij} - \frac{w_i w_j}{2W} \right)Cox Proportional Hazard function:
h(t) = h_0(t) \cdot e^{(\beta_1 x_1 + \cdots + \beta_n x_n)}Gradient boosting combined model:
F_k(x) = F_0(x) + gamma_0 * H_0(x) + gamma_1 * H_1(x) + ... + gamma_k * H_k(x)
where each H_i is trained on the negative gradient of the loss function evaluated at the current combined model's predictions.
Students often think the Louvain algorithm finds the optimal partition. It does not. It is a heuristic that finds a good solution quickly, but there is no guarantee it is the best possible one.
Students often confuse deep learning with neural networks in general. Deep learning is a subset: neural networks with many hidden layers. A neural network with one hidden layer is not "deep."
Students often think that in a prisoner's dilemma, the players are being irrational. They are not. Each player is individually rational; the dilemma is that individual rationality leads to a worse collective outcome.
Students often assume survival models only apply to death or failure. They apply to any time-to-event question: customer churn, insurance claims, equipment replacement.
Students often think gradient boosting trains all models at once. It does not. Models are added sequentially, each trained on the errors of the combined model so far.
Be able to explain the Louvain algorithm's steps and what modularity measures. Know that it is heuristic.
Know the three layers of a neural network and what each does. Be able to explain the difference between neural networks and deep learning.
The prisoner's dilemma (the BP/Shell example) is a classic exam question. Be able to identify the stable equilibrium and explain why the cooperative outcome is unstable.
Know the difference between pure and mixed strategies, and between zero-sum and non-zero-sum games.
Be able to interpret a Cox model's coefficients: what a positive, negative, or zero beta means for the hazard.
Understand the concept of censored data and why it is a challenge for survival models.
Know the gradient boosting loop: base model, compute errors, train correction model, add to ensemble, repeat.
True or false: The Louvain algorithm guarantees the globally optimal community partition. (False – it is a heuristic.)
Fill in the blank: In a neural network, the ________ layer is where weights are calculated from the inputs. (Hidden.)
True or false: In the prisoner's dilemma, the stable equilibrium is the outcome that maximises total payoff. (False – the equilibrium is collectively suboptimal.)
Fill in the blank: A Cox model coefficient of beta = 0 means the predictor has ________ on the hazard. (No effect.)
True or false: In gradient boosting, each new model is trained on the original response variable y. (False – it is trained on the errors/negative gradient of the current combined model.)
Q: A social network has 10,000 users. You want to find groups of users who interact heavily with each other. What algorithm would you use, and what does it optimise?
A: The Louvain algorithm. It optimises modularity, a measure of how well the network is partitioned into densely connected communities.
Q: Two petrol stations compete on price. Each can charge 2.50 or 2.00. If both charge 2.50, each earns 0.75d. If both charge 2.00, each earns 0.50d. If one charges 2.00 and the other 2.50, the cheaper station earns 1.00d and the other earns 0. What is the stable equilibrium, and why is this a prisoner's dilemma?
A: The stable equilibrium is both charging 2.00 (each earning 0.50d), because neither can improve by changing unilaterally. It is a prisoner's dilemma because both would earn more (0.75d each) at 2.50, but each has an incentive to undercut, driving them both to 2.00.
Q: In a Cox Proportional Hazard Model, predictor x_3 has coefficient beta_3 = -0.5. What does this mean?
A: A higher value of x_3 reduces the hazard (makes the event less likely at any given time). The multiplicative effect on the hazard is exp(-0.5 * x_3), which is less than 1 when x_3 is positive.
Q: You have a regression model F(x) with prediction errors of y - F(x). You train a second model H(x) on those errors. What is this technique called, and what is the combined prediction?
A: Gradient boosting. The combined prediction is F(x) + gamma * H(x), where gamma is a scaling factor. The process repeats, adding more correction models.
Q: Name three tasks that fall under Natural Language Processing.
A: Speech-to-text, named entity recognition, and sentiment analysis (also acceptable: co-reference resolution, text generation, contextual meaning detection).
Graph community detection connects to clustering methods covered earlier (k-means, hierarchical clustering). The difference is that community detection operates on network/graph structure rather than feature vectors.
Neural networks and deep learning connect forward to NLP, since deep learning is the engine behind most modern NLP systems. They also connect back to regression: a neural network with no hidden layer and a linear activation is just a linear regression.
Game theory connects to the optimisation and prescriptive-modelling material from earlier weeks. The distinction is that prescriptive models assume a static system, while game theory assumes the system reacts.
Gradient boosting connects to the iterative optimisation algorithms covered earlier. The idea of improving a solution by correcting residuals at each step is structurally similar to gradient descent, but applied at the model level rather than the parameter level.
Community detection, graph partitioning, modularity, Louvain algorithm, network analysis, clique, nodes, vertices, edges, arcs, neural network, artificial neural network, ANN, deep learning, hidden layer, backpropagation, weights, activation function, game theory, cooperative game theory, Nash equilibrium, stable equilibrium, prisoner's dilemma, payoff matrix, pure strategy, mixed strategy, zero-sum game, non-zero-sum game, perfect information, imperfect information, asymmetric information, NLP, natural language processing, speech-to-text, sentiment analysis, named entity recognition, text generation, survival model, survival analysis, time-to-event, Cox proportional hazard, hazard function, baseline hazard, censored data, right-censoring, gradient boosting, ensemble learning, residuals, loss function, negative gradient, XGBoost, boosting, model stacking, sequential modelling