Part IV · Ch. 13 — Choosing Your Tool

Part IV · Chapter 13 of 13

Choosing Your Tool

A field guide: from problem shape to model family


Review prerequisite concepts
  • The Classical Toolbox
  • Seeing Machines
  • Remembering Machines
  • Networks of Relationships

Choosing the tool

Twelve chapters ago, a "model" was a mystery. Now you can fit a line, grow a forest, stack a deep network, slide a convolution across an image, pass messages on a graph, denoise an image into existence, and train an agent by reward. The remaining skill is picking the right one. Given a problem you have never seen, how do you choose?

Shape and signal narrow the choice.
QuestionWhat decides it
Data shape?Rows, pixels, order, links
Learn from?Labels, data, rewards
Data size?Examples available
Explain it?Evidence required
Budget?Compute, time, skills

Ask which assumptions fit our data, not which model has the biggest reputation.

The five questions

Use the first two questions to narrow the field, then the last three to break ties.

A decision map read top to bottom. A start box 'a new problem' branches on Question 1, 'what SHAPE is the data?', into four downward paths: 'TABLE — rows and columns' to an amber pill 'classical: trees / forests / boosting'; 'GRID — image' to a blue pill 'CNN'; 'SEQUENCE — text / audio' to a mint pill 'transformer / LLM'; 'GRAPH — nodes and edges' to a violet pill 'GNN'. Under the TABLE branch a small fork on 'have labels?' reads 'yes to supervised (trees)' and 'no to unsupervised (k-means / PCA)'. Off to the side, a separate boxed side-note 'no dataset, only a reward?' points to a muted pill 'reinforcement learning'. A bottom band lists three tie-breaker chips — 'how much data?', 'need to explain?', 'budget?' — with a note 'when two tools fit, the simpler / cheaper / more explainable one wins'.
Data shape suggests a model family, while labels or rewards determine how it can learn.
QuestionWhat to look forFirst direction
1. Shape?Table: rows and columns; grid: neighboring pixels; sequence: ordered text or audio; graph: entities linked without a natural order.Classical methods; CNN; transformer; GNN, respectively.
2. Learn from what?Labels give the right answer; unlabeled data gives structure; rewards grade actions.Supervised classification/regression; unsupervised k-means/PCA; reinforcement learning.
3. How much data?Hundreds of examples versus thousands to millions.With little data, favor classical methods or a pre-trained model.
4. Must decisions be explained?Medical, credit, or legal decisions may require interpretable evidence.Consider a linear model or small tree, and examine the accuracy tradeoff.
5. What budget?Compute, time, and expertise.A boosted tree may train in seconds on a laptop; a large network can require much more.

These are starting points to measure, not guarantees. Make a deep network earn its complexity against a baseline that fits the problem.

The video's table case: payment fraud

Payment dataStarting modelWhat to measure
Independent labeled rowsBoosted treesMissed fraud and false alarms
Linked accountsGraph-aware modelBenefit of keeping connections
Either representationA cheap baselinePrediction cost and held-out performance

For the video's card-payment example, suppose we have millions of labeled payment rows. Each row holds a payment's features; fraud/not-fraud is the label. Begin with boosted trees. Explanation needs mean examining which features drive flags; an ensemble is not as transparent as one small tree. Compare a cheaper baseline and measure missed fraud, false alarms, and prediction cost. If links between accounts carry extra evidence, the problem has acquired a graph, which is the second path the video takes.

Five questions about the data route two different problems to two different tools, which is the judgment the whole book has been building. (2:23)

Six problems, six choices

Question about a payment modelEvidence to inspect
AccuracyMissed fraud and false alarms
ExplanationWhich features drive flags
CostTime and resources per prediction

Scenario 1: predict a house's price from a spreadsheet of features: square footage, bedrooms, zip code. Shape: a table. Learn from: labels, since each house has a sold price, a number, so this is regression. Size: a few thousand rows. Verdict: start with plain linear regression as a baseline, which takes seconds, then reach for gradient-boosted trees from the classical toolbox for accuracy. With a few thousand rows, make a neural network earn its extra training effort against that baseline.

  1. ShapeTable.
  2. SignalNumeric labels: regression.
  3. First trialLinear baseline, then boosted trees.

Scenario 2: split your customers into natural groups you never defined in advance. Shape: a table again. Learn from: no labels at all, because nobody tagged these customers. Verdict: this is unsupervised, so k-means to find the clusters and PCA to squash the features down and see them, both from the classical toolbox. With no labels there is nothing for a network to fit; find the structure that is already there.

  1. ShapeCustomer rows.
  2. SignalNo labels: find structure.
  3. First trialk-means groups; PCA view.

Scenario 3: flag likely pneumonia on chest X-rays. Shape: a grid of pixels, where a pixel's meaning is set by its neighbors. Learn from: labels, namely radiologist-confirmed cases. Size: large. Verdict: a convolutional neural network from seeing machines, the tool built for grids, likely starting from one pre-trained on millions of images and fine-tuned on the X-rays. There is a tension here: medicine wants explanations, and a CNN is less transparent than a tree, so in practice it is paired with heat-maps showing where it looked, with a doctor in the loop. The grid makes a CNN a useful candidate; heat maps alone do not establish that its decisions are sound.

  1. ShapePixel grid.
  2. SignalConfirmed case labels.
  3. First trialFine-tune a CNN; check errors and explanations.

Scenario 4: build a support chatbot that answers in fluent prose. Shape: a sequence, because language carries its meaning in order and long-range context. Learn from: a mountain of unlabeled text (self-supervised pretraining) plus human preferences for the polish. Verdict: a transformer, which is a large language model, the subject of the entire sister site, finished with the RLHF from learning by doing to steer it toward helpful behavior, which still needs evaluation. The shape (a sequence) and the task (generation) both point at one family.

  1. ShapeText sequence.
  2. SignalText, then preferences.
  3. First trialPre-trained language model; evaluate helpfulness.

Scenario 5: teach a warehouse robot to grasp and stack items nobody demonstrated. Shape: a stream of decisions over time. Learn from: no labeled "correct grasp" exists, only a reward when the item ends up stacked. Verdict: reinforcement learning from learning by doing, trained in a physics simulator where it can fail ten thousand times without damaging hardware before touching a real shelf. No labels and a reward per outcome is what RL is for.

  1. ShapeActions over time.
  2. SignalReward for stacking.
  3. First trialReinforcement learning in simulation.
ProblemShapeAnswerWhy
House prices: square footage, bedrooms, zip codeTable; a few thousand labeled sale pricesLinear regression, then boosted treesNumeric labels make this regression; start with an interpretable baseline.
Natural customer groupsUnlabeled tablek-means / PCACluster similar customers; reduce dimensions to inspect structure.
Pneumonia flags on chest X-raysLarge labeled image gridCNNFine-tune features learned from millions of images; review heat maps and retain a doctor’s judgment.
Support chatbotText sequence plus human preferencesTransformer / LLM + RLHFSelf-supervised text training learns language; preferences train helpful behavior.
Warehouse grasping and stackingDecisions over time; outcome rewardsReinforcement learningNo demonstrated grasp labels; a simulator permits ten thousand failed attempts before a real shelf.
Coordinated communications netLabeled contact graphGNNConnections carry the signal; retain them explicitly.

The one where the answer is a graph network

Scenario 6: triage whether a cluster of accounts is a coordinated network from its contact pattern, before reading the traffic. Run the five questions:

On the left, a small communications network drawn as a graph: five stations as labeled circles — call signs A2 and D4 in muted gray, a violet relay 'RLY', a blue net control station 'NCS' — joined by lines, one drawn heavy and noted 'heavy line = high-volume link'. One station, B7, is highlighted mint with small mint arrows to the stations it contacts, labeled 'the mint station passes messages to the stations it contacts'. Header 'a comms net IS a graph — stations are nodes, contacts are edges'. On the right, under the header 'flatten it, and you delete the structure', three small chips each marked with a red cross: a mini table '5 nodes, 4 links' captioned 'as a TABLE of counts — two nets, same counts'; a 3 by 3 pixel grid captioned 'as an IMAGE — a net is not a grid'; a token strip 'A2 to B7 to D4' captioned 'as a SEQUENCE (a call log) — an arbitrary line through a web'. A violet verdict pill reads 'a GNN keeps the graph → the tool whose wiring matches the network'.
Stations and contacts form a graph; summary counts alone cannot distinguish different connection patterns.

The contact pattern is the evidence: a hub coordinating several accounts can matter even when each account’s traffic looks ordinary. Historical labels tell us which whole clusters were coordinated, so this is supervised classification of graphs. With tens of thousands of labeled clusters, we can test whether learning those neighborhoods helps on unseen clusters. A graph network is a candidate because its wiring keeps that evidence available; the baseline and the held-out score still decide whether it earns its cost.

  1. Shape: accounts are nodes; contacts are edges, with no natural starting account or left-to-right order.
  2. Learning signal: historical clusters have known coordinated/not-coordinated labels: supervised classification.
  3. Amount: tens of thousands of labeled clusters support learning; still test on unseen clusters.
  4. Explanation: inspect which neighborhoods support the triage, and check whether that evidence meets the task’s needs.
  5. Budget: compare a graph-aware model against a cheap baseline; preserve connections if they carry the answer.
RepresentationWhat it risks losing
Table of countsTwo nets can both have 5 nodes and 4 links yet differ in wiring; hub-and-spoke and loose crowds can share counts.
Image of the graphDrawing software introduces a 2D layout that is not part of the contact data.
Time-ordered contact logA transformer can work, but must recover relationships from the event sequence.

A GNN starts each account with features such as volume, timing, and age; repeated message passing mixes its neighbors’ information. A readout pools the resulting vectors into a graph-level verdict. The representation preserves the connections that aggregate counts omit.

The same clue appears in fraud rings, recommendations, and road networks: ask whether relationships carry information beyond the individual entities.

Walk it yourself

Try the questions on your own problem. The chooser names a first model family, explains its recommendation, and links back to the relevant chapter.

  1. Load presets: compare all six scenarios.
  2. House prices: require an explanation for each decision; watch the advice favor a tree or linear model.
  3. Coordinated net: change graph to table; the chooser now recommends boosted trees because the stated shape changed.

The controls describe the problem you give them; they cannot detect that you discarded useful connections. Start with the simplest fitting model, measure it, and add complexity only when the results justify it.

What to keep

You started this site unable to read a vector. You can now stand in front of an unfamiliar problem, read the shape of its data, name the family that fits, and say why. That includes saying that a boosted tree often beats a neural network, and that a web of relationships wants a graph network.

PrincipleWhat to do
Start simpleBuild a baseline you can debug; require each increase in complexity to improve its measured result.
No free lunchCompare models on this task; success on images says little about a spreadsheet.
Structure is signalAsk which grid, sequence, or graph relationships the model ignores.
Costs countMeasure training time, serving cost, interpretability, and effort as well as accuracy.

We kept returning to a flexible function, a loss, and gradient descent. Neural networks share this update; trees, neighbor methods, and other classical tools have their own fitting procedures.

$$\theta \leftarrow \theta - \eta\,\nabla L$$

In words: nudge every parameter ($\theta$, theta, the numbers the model learns) a small step of size $\eta$ (eta, the learning rate) against $\nabla L$, the gradient of the loss, which is the direction in which wrongness climbs fastest. A small enough step against it lowers the loss locally. For models trained this way the update has not changed since fitting a line. Choosing a model is choosing the shape that goes around it.

Where you've been

WhereWhat it looks likeChapter link
Your next projectRead the data shape, choose a baseline, and measure on held-out dataTraining and evaluation
Language modelsVectors become text representations, attention, and next-token predictionsHow LLMs Actually Work
Across the booksUse this broad map to place the transformer’s detailed arithmeticThe starting map

What you now know

  • Choose a model by the problem’s shape and learning signal, then consider size, explanation, and budget.
  • Tables, grids, sequences, and graphs suggest different useful assumptions.
  • Contact patterns call for a representation that preserves connections.
  • Start with a simple baseline and measure whether extra complexity earns its cost.
  • Training mechanics matter, but choosing and evaluating the right problem comes first.

Where we’re headed. This book ends here. How LLMs Actually Work opens the transformer from vectors to an assistant. You asked how these things work, the whole family of them and not just the famous one, and you can now answer that with arithmetic. Go build the right thing.