Probabilistic Modeling
A probabilistic model lets machine learning or probabilistic inference estimate how much to trust each measurement and what the best guess for the user's location is.
The Pile-Everything-In Instinct
A common first instinct in applied machine learning is to gather every signal you can, hand the whole pile to a learning algorithm, and let it sort out the rest. Many software libraries make this easy because they ship with ready-made models that apply one particular algorithm to whatever inputs you provide. That convenience hides a question worth asking before you reach for those tools: does the problem you are solving already have shape that you know about? In many real situations it does, and that shape can be used to produce far better predictions than a generic model working from raw inputs alone.
Imagine a system tracking someone's walk through an outdoor space. Two of its sensors disagree about the direction of travel, and you must decide which reading to rely on. Before reading further, reason it out: what would you need to know about each sensor, and about the space itself, to decide which reading deserves more trust?
Hints
- Think about what each sensor measures and whether it reports an absolute position or a change relative to a moment ago.
- Think about whether you know anything about the space, such as which paths exist, that could rule out some readings.
Where Black-Box Models Waste Knowledge
The belief this article targets is that a black-box system can be trusted to discover everything relevant on its own. In this view, the model is a container: you pour in the readings, it returns a prediction, and the internal reasoning is someone else's problem. The belief is tempting because it avoids the hard work of writing down what you already know about the world.
The problem with the shortcut is what it throws away. If you have a detailed map, knowledge of which paths exist, or a clear sense of how a measurement device behaves, then discarding that knowledge and relying only on the raw numbers means the model must rediscover those facts from examples. Sometimes it can, but there is no guarantee, and you have given up a source of information that was available to you for free.
What Makes a Problem Structured
A structured problem is one whose shape can be written down in the language of probability theory. That shape usually comes from having a mathematical model of the situation you want to predict.
The source is clear that the structure is not something the algorithm invents. It is knowledge about the situation that you encode deliberately. This is why the first question to ask is not which library to use but what you already know about how the situation works. Once that knowledge is written down in probabilistic terms, it becomes part of the model rather than something a learner must guess from data.
Structure comes from knowledge you encode, not from the algorithm. Ask what you already know about the situation before choosing tools.
Tracing a Navigation Scenario
Consider a mobile application that gives a detailed position estimate in an outdoor space, such as a historical site, so that visitors can find their way. The phone offers several sensors that produce location-related measurements: a GPS receiver, an accelerometer, and a compass. You also have an exact map of the area, which tells you where the paths and points of interest are.
Notice how the measurements differ in character. The GPS gives rough positions. The accelerometer and compass give very precise relative measurements, meaning they are good at telling you how the user is moving compared with a moment ago, even if they do not pin down an absolute location on their own. The map gives you a set of facts about the world that any honest location estimate must respect.
Reading one navigation estimate against the map
The GPS reports a rough position that falls near a wall, while the accelerometer and compass indicate the user has been moving steadily along a direction that follows a path. Which information should shape the final estimate, and how?
- 1Identify the measurement types
The GPS is rough about absolute position. The accelerometer and compass are precise about relative motion and direction.
- 2Apply the map constraint
The map says a position inside a wall is implausible, so candidate locations inside the wall are ruled out before the measurements are weighed.
- 3Weigh the remaining candidates
Among positions on paths, the precise relative readings favor candidates consistent with the recent movement, while the rough GPS reading contributes less certainty about exactly where along the path the user is.
- 4Form the estimate
The best guess combines these pieces: the map removes impossible answers, the precise readings guide movement, and the rough GPS reading still contributes, but with less weight.
The final estimate is a position on a path, shaped more by the precise relative readings than by the rough GPS reading, and never inside a wall.
Weighing Measurements by Trust
Probabilistic modeling is the practice of using probability theory to express a problem's structure. In the navigation example, a probabilistic model can state how likely each measurement is given the user's actual position, and how likely a position is given the map. Once the structure is written this way, machine learning or probabilistic inference can be used to answer two questions: how much should you trust each measurement, and what is the best guess for the user's location?
The idea of trust here is that a measurement with high uncertainty should pull the final estimate less than a precise measurement does. A rough GPS reading still contributes, but it contributes less than a precise reading of relative movement when the two disagree about how the user is moving. The model's job is to combine all contributions according to how reliable each one is, rather than treating every reading as equally important.
Three Stages From Situation to Prediction
Machine learning often starts with a situation that has several factors influencing an outcome. To make predictions about that outcome, you first describe the situation and your model of how the different factors work together. Once that description is in place, you still need a way to compute predictions from the custom model you have built. This article focuses on that second step, which is handled by a family of tools called probabilistic programming languages.
The order matters. Expressing the situation comes first, then modeling how the factors work together, and only then using a probabilistic programming language to compute predictions. Probabilistic programming languages belong to the third step. The diagram reads from left to right and shows the order of work, not a loop.
What a Probabilistic Programming Language Does
Probabilistic programming languages are described in the source as the most general methods for computing predictions directly from a custom model. Their main value is that they let you express a learning problem in a very elegant and compact way. In terms of the pipeline, the language takes in the model you wrote down and the data, performs the computation needed to produce predictions, and returns those predictions to you.
PyMC and Stan Compared
The source names two popular probabilistic programming languages. Both serve the same general purpose, but the source describes them in different ways. The table below summarizes only what the source states about each one.
| Tool | Relationship to Python | What the source states |
|---|---|---|
| PyMC | Can be used in Python | A tool you can use in Python |
| Stan | A framework usable from several languages, including Python | Not limited to Python; Python is one of several languages it can be used from |
What the source says about PyMC and Stan
The main difference the source emphasizes is the scope of use. The source does not compare performance or features, so you should not draw conclusions beyond this scope.
Misreadings of the Workflow
Common mistake Assuming the black-box approach is safe because it sees all the data
What it looks likeFeeding raw sensor readings into a generic model while ignoring a detailed map of the paths.
Why it failsKnowledge you already have, such as which paths exist, is discarded and must be rediscovered from examples, with no guarantee that it will be.
Do this insteadAsk first what you already know about how the situation works, and encode that structure in the model.
Common mistake Treating every measurement as equally trustworthy
What it looks likeGiving a rough GPS reading the same weight as a precise accelerometer reading of relative movement.
Why it failsA measurement with high uncertainty should pull the final estimate less than a precise measurement.
Do this insteadLet the probabilistic model weigh each measurement by how much it can be trusted.
Common mistake Believing the probabilistic programming language chooses the factors
Why it failsThe source places the choice of situation and factors with the modeler, and the language works with the model you wrote down.
Do this insteadDecide the factors and their relationships yourself, then use the language to compute predictions.
Common mistake Believing the tools remove the need to understand probability theory
Prerequisites Before Simplified Model Creation
The source states that these tools significantly simplify the creation of new models, but they still require some understanding of probability theory. The tools lower the effort of building a model; they do not replace the knowledge needed to express a structured problem in probabilistic terms.
Trace a Scenario Yourself
Take a different outdoor scenario, such as a visitor following a path that bends around a building. List the measurements available, mark each as precise or rough, and name at least one candidate location the map would rule out. Then write the three stages in order: the situation and factors, the custom model, and the probabilistic programming language that computes the prediction.
Hints
- Ask which sensors report absolute position and which report how the user is moving relative to a moment ago.
- Ask what the map says about where the user can physically be, and which candidate positions that makes implausible.
- Remember that the modeler decides the factors; the language only computes predictions from the model.
Key Takeaways
- A structured problem is one whose shape can be written in probability theory, usually because you have a mathematical model of the situation; that knowledge is encoded deliberately rather than invented by the algorithm.
- A probabilistic model expresses how likely each measurement is given the true position and how likely a position is given the map, so it can estimate how much to trust each measurement and what the best guess for the location is.
- The workflow runs in order: express the situation, model how the factors work together, then use a probabilistic programming language to compute predictions from the custom model.
- PyMC can be used in Python, while Stan is a framework usable from several languages, including Python; both still require an understanding of probability theory.