📚 Probabilistic Graphical Models and Bayesian Networks | 概率图模型与贝叶斯网络
Probabilistic graphical models are a powerful framework for representing complex probabilistic relationships among many variables. They combine graph theory with probability theory to provide a compact and interpretable way of modelling uncertainty in fields such as machine learning, artificial intelligence, and statistics.
概率图模型是一种强大的框架,用于表示众多变量之间复杂的概率关系。它将图论与概率论相结合,为机器学习、人工智能和统计学等领域中的不确定性建模提供了一种紧凑且可解释的方式。
1. What Are Probabilistic Graphical Models? | 什么是概率图模型?
A probabilistic graphical model is a graph in which nodes represent random variables and edges represent probabilistic dependencies between those variables. The graph is combined with a set of probability distributions, so that the entire model defines a joint probability distribution over all variables.
概率图模型是一种图结构,其中节点代表随机变量,边代表这些变量之间的概率依赖关系。该图与一组概率分布相结合,使整个模型定义了所有变量的联合概率分布。
Why is this useful? Without a graphical structure, representing the joint distribution of n binary variables would require 2ⁿ − 1 independent probabilities. This quickly becomes impossible for large n. Graphical models exploit conditional independence relationships to break this exponential growth into smaller, more manageable local factors.
为什么这很有用?如果没有图结构,表示 n 个二值变量的联合分布需要 2ⁿ − 1 个独立概率。对于较大的 n,这很快变得不可行。图模型利用条件独立关系将这种指数增长分解为更小、更易管理的局部因子。
2. Key Components of a Graph | 图的关键组成部分
Before diving into the probabilistic part, we need to recall some basic graph theory. A graph G = (V, E) consists of a set of vertices V and edges E. Each vertex corresponds to a random variable. Edges can be either directed (an arrow from one vertex to another) or undirected (a simple line).
在深入概率部分之前,我们需要回顾一些基本的图论知识。图 G = (V, E) 由顶点集 V 和边集 E 组成。每个顶点对应一个随机变量。边可以是有向的(从一个顶点指向另一个顶点的箭头)也可以是无向的(一条简单直线)。
- Directed edge X → Y means that X directly influences Y. | 有向边 X → Y 表示 X 直接影响 Y。
- Undirected edge X − Y means that X and Y are related, but without a specified causal direction. | 无向边 X − Y 表示 X 和 Y 相关,但没有明确的因果方向。
In this article, we focus mainly on graphs that are directed acyclic graphs, abbreviated as DAGs, which form the basis of Bayesian networks.
在本文中,我们主要关注有向无环图(简称 DAG),它是贝叶斯网络的基础。
3. Directed Acyclic Graphs (DAGs) | 有向无环图(DAG)
A directed graph is acyclic if it contains no directed cycles. A directed cycle is a path that starts at one vertex and returns to the same vertex by following the direction of the edges. For example, a graph with edges X → Y, Y → Z, and Z → X contains a cycle and cannot be used as a Bayesian network.
如果一个有向图不包含任何有向环,则它是无环的。有向环是指从某个顶点出发,沿着边的方向经过若干边后又回到同一顶点的路径。例如,一个包含边 X → Y、Y → Z 和 Z → X 的图存在环,因此不能用作贝叶斯网络。
Why must a Bayesian network be acyclic? Because cycles would imply circular causality, making it impossible to define a consistent joint probability distribution through recursive conditional probabilities.
为什么贝叶斯网络必须是无环的?因为环意味着循环因果,使得通过递归条件概率定义一致的联合概率分布成为不可能。
4. What Is a Bayesian Network? | 什么是贝叶斯网络?
A Bayesian network is a probabilistic graphical model that combines a DAG with conditional probability distributions. Each node in the DAG has a conditional probability table (CPT) that specifies how its value depends on the values of its parents in the graph.
贝叶斯网络是一种概率图模型,它将 DAG 与条件概率分布相结合。DAG 中的每个节点都有一个条件概率表(CPT),用于说明其取值如何依赖于图中父节点的取值。
The full joint distribution is written as the product of every node’s conditional probability given its parents:
完整的联合分布可以写成每个节点在给定其父节点条件下的条件概率的乘积:
P(X₁, X₂, …, Xₙ) = ∏ P(Xᵢ | Parents(Xᵢ))
This is known as the chain rule for Bayesian networks. It drastically reduces the number of parameters needed compared with a full joint distribution.
这被称为贝叶斯网络的链式法则。与完整的联合分布相比,它大大减少了所需参数的数量。
5. Conditional Independence | 条件独立性
One of the greatest strengths of Bayesian networks is their ability to represent conditional independence. In a Bayesian network, a node is conditionally independent of its non-descendants given its parents. This is called the local Markov property.
贝叶斯网络最大的优势之一在于它能够表示条件独立性。在贝叶斯网络中,给定节点的父节点,该节点与其非后代节点条件独立。这称为局部马尔可夫性质。
Consider a simple network: A → B → C. Here, C depends on B, but once B is known, C does not depend on A directly. Formally, P(C | A, B) = P(C | B). This form of independence is central to efficient inference.
考虑一个简单网络:A → B → C。这里,C 依赖于 B,但一旦 B 已知,C 不再直接依赖于 A。形式上,P(C | A, B) = P(C | B)。这种独立性是高效推理的核心。
Another important concept is d-separation. Two sets of variables are conditionally independent given a third set if every path between them is “blocked” by the conditioning variables. Paths can be blocked in three ways:
另一个重要概念是 d-分离。如果两变量集合之间的每条路径都被条件变量“阻断”,则这两个集合相对于条件变量是条件独立的。路径可以通过三种方式被阻断:
- Chain: X → Z → Y, with Z observed. | 链式: X → Z → Y,且 Z 已被观测。
- Fork: X ← Z → Y, with Z observed. | 分叉式: X ← Z → Y,且 Z 已被观测。
- Collider: X → Z ← Y, with Z and none of its descendants unobserved. | 对撞式: X → Z ← Y,且 Z 与其所有后代均未被观测。
6. Building a Bayesian Network: The Sprinkler Example | 构建贝叶斯网络:洒水器示例
A classic pedagogical example is the sprinkler network. It involves four variables: Rain (R), Sprinkler (S), Grass wet (G), and Season (Q). A simplified version uses only Rain and Sprinkler, both of which can cause the grass to become wet.
一个经典教学示例是洒水器网络。它涉及四个变量:下雨(R)、洒水器(S)、草地湿润(G)和季节(Q)。我们考虑一个简化版本,只包括下雨和洒水器,它们都可能导致草地湿润。
Suppose we have the following conditional probability tables:
假设我们有以下条件概率表:
| P(R = true) | 0.2 |
| P(S = true) | 0.1 |
| P(G = true | R, S) | R=true: 0.9, R=false: 0.7 if S=true; R=false, S=false: 0.01 |
These tables fully define the joint distribution of the three variables.
这些表完整地定义了三个变量的联合分布。
7. Probabilistic Inference in Bayesian Networks | 贝叶斯网络中的概率推理
Inference in a Bayesian network means computing the posterior probability of one or more variables given evidence about some other variables. For example, in the sprinkler network, given that the grass is wet, we might want to know the probability that it rained. This is written as P(R = true | G = true).
贝叶斯网络中的推理是指在已知其他变量证据的情况下,计算一个或多个变量的后验概率。例如,在洒水器网络中,给定草地湿润,我们可能想知道下雨的概率。这写作 P(R = true | G = true)。
The naive way to reason is to use the joint distribution directly:
最直接的方法是直接使用联合分布:
P(R | G) = P(R, G) / P(G)
The denominator P(G) is computed by marginalising out the other variables in the network.
分母 P(G) 通过对网络中的其他变量进行边缘化来计算。
8. Enumeration for Exact Inference | 精确推理的枚举方法
One simple exact inference approach is enumeration. It sums over all possible values of the hidden variables to compute the desired marginal probability. For the sprinkler network, this means summing over both Rain and Sprinkler.
一种简单的精确推理方法是枚举。它通过求和所有可能隐藏变量的取值来计算所需的边缘概率。对于洒水器网络,这意味着对 Rain 和 Sprinkler 求和。
For example, to compute P(R | G = true):
例如,为了计算 P(R | G = true):
P(R | G = true) = α P(R) ∑ₛ P(S) P(G = true | R, S)
Here α is a normalisation constant that ensures the probabilities sum to 1. Enumeration is correct but inefficient, because the number of terms grows exponentially with the number of hidden variables.
这里 α 是一个归一化常数,确保所有概率之和为 1。枚举方法是正确的,但效率低下,因为项的数量随着隐藏变量的数量呈指数增长。
9. Variable Elimination and Approximate Inference | 变量消元与近似推理
Variable elimination is a more efficient exact inference algorithm. It works by eliminating variables one by one from the joint distribution, using dynamic programming. By factoring out common terms, it avoids the exponential blow-up of naive enumeration in many practical cases.
变量消元是一种更高效的精确推理算法。它通过动态规划,逐一从联合分布中消去变量。通过提取公共因子,它避免了许多实际情况下朴素枚举的指数爆炸。
When exact inference is too costly, Monte Carlo simulation methods such as Gibbs sampling and rejection sampling are used. These approximate methods generate many random samples from the network and estimate probabilities from the frequencies observed in those samples.
当精确推理成本过高时,可以使用蒙特卡洛模拟方法,例如吉布斯采样和拒绝采样。这些近似方法从网络中生成大量随机样本,并根据样本中观测到的频率来估计概率。
10. Undirected Graphs: Markov Networks | 无向图:马尔可夫网络
Not all graphical models use directed edges. In some problems, dependencies are symmetric and cannot be naturally expressed with arrows. Markov networks, also called Markov random fields, use undirected edges to represent correlations between variables.
并非所有图模型都使用有向边。在某些问题中,依赖关系是对称的,无法自然用箭头表达。马尔可夫网络,也称为马尔可夫随机场,使用无向边来表示变量之间的相关性。
In a Markov network, the joint distribution is expressed as a product of potential functions (also called factors) over cliques, or fully connected subgraphs. Unlike Bayesian networks, Markov networks cannot directly encode causal direction.
在马尔可夫网络中,联合分布被表示为团(即完全连接的子图)上势函数(也称因子)的乘积。与贝叶斯网络不同,马尔可夫网络不能直接编码因果方向。
Both directed and undirected models are called probabilistic graphical models. The choice between them depends on whether the underlying domain is causal or simply correlational.
有向图模型和无向图模型统称为概率图模型。它们之间的选择取决于所研究领域是因果关系还是仅相关关系。
11. Applications in Computer Science | 在计算机科学中的应用
Bayesian networks and their variants are widely used in computer science and engineering. In medical diagnosis, a network may contain nodes for diseases and symptoms, and inference can compute the most likely disease given observed symptoms.
贝叶斯网络及其变体在计算机科学和工程中应用广泛。在医疗诊断中,网络可能包含疾病和症状的节点,推理可以在给定观测症状的情况下计算最可能的疾病。
In natural language processing, probabilistic graphical models form the backbone of hidden Markov models and conditional random fields, used for part-of-speech tagging and named entity recognition. Speech recognition systems also use dynamic Bayesian networks to model the temporal evolution of acoustic features.
在自然语言处理中,概率图模型是隐马尔可夫模型和条件随机场的基石,这些模型被用于词性标注和命名实体识别。语音识别系统也使用动态贝叶斯网络来模拟声学特征的时间演变。
In expert systems and robotics, graphical models help make decisions under uncertainty. Autonomous vehicles, for instance, use them to fuse data from multiple sensors and estimate the state of the surrounding environment.
在专家系统和机器人学中,图模型帮助在不确定性下做出决策。例如,自动驾驶车辆使用它们来融合多个传感器的数据,并估计周围环境的状态。
12. Advantages, Limitations, and Summary | 优势、局限性与总结
The main advantages of Bayesian networks are their interpretability, their ability to handle missing data, and their clear separation of structural knowledge from quantitative probabilistic tables. They also support both deductive and abductive reasoning.
贝叶斯网络的主要优势在于其可解释性、处理缺失数据的能力,以及将结构知识与定量概率表清晰分离的特点。它们同时支持演绎推理和溯因推理。
However, learning the graph structure from data is computationally hard, and inference itself is NP-hard in general. Thus, for large networks, we often rely on approximate methods or impose simplifying assumptions.
然而,从数据中学习图结构在计算上是困难的,而且推理本身通常是 NP 困难问题。因此,对于大型网络,我们通常依赖近似方法或施加简化假设。
In summary, probabilistic graphical models balance between representational power and computational tractability. Bayesian networks use directed acyclic graphs to exploit conditional independence, making it possible to reason about uncertainty in complex systems in a principled and efficient manner.
总而言之,概率图模型在表示能力和计算可行性之间取得了平衡。贝叶斯网络利用有向无环图来利用条件独立性,从而能够以有原则且高效的方式对复杂系统中的不确定性进行推理。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导