An image might show a 4 or a 9. Rather than force an answer immediately, probabilistic reasoning asks how likely each label is given the observed pixels. It represents uncertainty with distributions over variables, then uses evidence to make predictions or decisions. A practical workflow is to pose a question, identify the probability or expectation that answers it, and estimate that quantity. section 1.5.1
Conditioning is the central move: P(D=4 | I) means the probability that the digit D is 4 given image I. If a generative process samples from P(X, Y, Z), asking for P(Z | Y=3) reverses the direction of inquiry: retain or infer the values of Z compatible with the observed Y. Probabilistic inference algorithms turn a model and a target distribution into a way to generate samples from that target. section 1.5.1 section 2.2.5
Choose an inference method that fits the model and evidence:
- For a simple simulated process, generate outcomes, discard those that fail the condition, and average the retained values. This accept/reject approach becomes inefficient when the condition is rare. section 2.2.5
- For a tabular graphical model, use variable elimination to calculate a conditional probability table. For a Pyro model, condition the model and use importance sampling to approximate the distribution. section 3.1.11
What does a commute reveal?
A graphical model can compare P(E | T=car) with P(E | T=train), where E is education and T is transportation. Its probability tables assign university education probabilities of 0.4414 for car drivers and 0.3838 for train riders. These are inferences conditional on observed transportation, based on the model’s assumed causal graph—not estimates of what changing someone’s transportation would do to their education. section 3.1.11
Listing 3.7 Inference on the trained causal graphical model
from pgmpy.inference import VariableElimination #1
inference = VariableElimination(model)
query1 = inference.query(['E'], evidence={"T": "train"})
query2 = inference.query(['E'], evidence={"T": "car"})
print("train")
print(query1)
print("car")
print(query2)
The pgmpy listing shows how to request and compare both conditional education distributions with variable elimination. section 3.1.11
A conditional prediction is not automatically a causal answer: correlation alone cannot establish cause and effect. Causal reasoning changes the question and the mathematical target by specifying an intervention, effect, or counterfactual under causal assumptions. Once a causal generative model represents the target intervention, probabilistic inference can operate on the transformed model. For an average treatment effect, this can include estimating model parameters from data before applying an intervention operator and sampling; without that data-fitting step, calculating the effect from a specified model is not estimation. section 1.1 section 11.6
Counterfactual reasoning also uses ordinary probabilistic inference as a component. In abduction, observed outcomes update a distribution over latent exogenous variables—the possible underlying conditions compatible with what happened. The resulting inference remains dependent on the specified model and its assumptions. section 9.1.1 section 1.1
