Probability models
مُقدَّم
6:33
الذكاء الاصطناعي والتعلم الآلي
This course covers the classical core of artificial intelligence, honestly measured. The first three units are the spine: search, logical reasoning and…
سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما
في هذا الدرس
| English | المعنى |
|---|---|
| Bayesian network/beɪˈiːzɪən ˈnetwɜːk/ | الشبكة البايزية |
| conditional probability table/kənˈdɪʃənl ˌprɒbəˈbɪlɪti ˈteɪbl/ | the probabilities of a variable for each combination of its parents' values |
| marginalising/ˈmɑːdʒɪnəlaɪzɪŋ/ | summing a probability over the values of a variable to remove it |
| d-separation | |
| naive Bayes/naɪˈiːv beɪz/ | a classifier that assumes the features are independent given the class |
| Laplace smoothing/ˈlæpleɪs ˈsmuːðɪŋ/ | adding one to every count so that no probability is zero |
| conditional independence/kənˈdɪʃənl ˌɪndɪˈpendəns/ | two variables are independent once a third is known |
The network and the numbers
- A Bayesian network 贝叶斯网络 is a directed acyclic graph of variables, each with a conditional probability table 条件概率表. Inference multiplies along the graph and then normalises.
- The course network: Storm → Delay → {Late, Complaint}.

A Bayesian network factorises —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Each node keeps a CPT given its parents; the joint is their product.
Bayes, in the small
- The tables for Storm, Delay and Complaint:
| Node | Given | Probability |
|---|---|---|
| Storm | — | $P(S) = 0.3$ |
| Delay | storm / none | 0.8 / 0.1 |
| Complaint | delay / none | 0.6 / 0.05 |
- First sum over D (marginalising 边缘化): each route to a complaint, weighted by how likely it is.
- Then Bayes, over all storms and none:
- The joint distribution of the 4 binary variables has 16 rows; summing the rows for $S$ and $C$ and dividing by the sum of the rows for $C$ gives the same 0.667. Exact inference on a small network is careful bookkeeping, and the bookkeeping is the derivation.
Storm to delay, and back
With P(S) = 0.3, P(D | S) = 0.8 and P(D | ¬S) = 0.1, a delay raises the belief in a storm from 0.3 to 0.24 / 0.31 ≈ 0.77. Lower P(S) towards rare storms and watch the posterior fall.
With the course numbers, P(Storm | Complaint) = —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
0.49 x 0.3 / 0.2205 = 0.667 - marginalise D both ways first.
The base rate matters
- With $P(S) = 0.03$ (rare storms): $P(C) = 0.11655$ and $P(S \mid C) = \mathbf{0.126}$. The evidence is the same, but the belief falls to about one-eighth. Rare causes need strong evidence.
- Watch for two mistakes: leaving out the normaliser $P(C)$, and swapping $P(C \mid S)$ for $P(S \mid C)$ (the prosecutor's fallacy). Whether two variables depend on each other is decided by d-separation d-分离 in the graph, not by a single missing edge.
Reducing the storm prior to 0.03 moves the posterior to —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Rare causes need strong evidence: 0.667 falls to 0.126.
Naive Bayes
- A naive Bayes 朴素贝叶斯 classifier assumes the features are independent once the class is known. A spam filter, where ham is normal email:
| Spam | Ham | |
|---|---|---|
| Prior | 0.4 | 0.6 |
| P("free" | class) | 0.5 | 0.05 |
| P("win" | class) | 0.3 | 0.02 |
| Score: multiply down | 0.06 | 0.0006 |
- For an email with both words, divide the spam score by the sum of the two:
- A word never seen in ham gives a zero that wipes out all the other evidence, so Laplace smoothing 拉普拉斯平滑 adds one to every count. The independence assumption is wrong, but the ranking it gives is often right.
Using the step's numbers, an email contains only the word free. What is P(spam | free)? (Answer to 2 decimal places.)
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Spam 0.4 x 0.5 = 0.2; ham 0.6 x 0.05 = 0.03; 0.2 / 0.23 = 0.87.
Without smoothing, one word never seen in a class sets that class's probability to zero.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
The product of likelihoods includes a factor of 0, whatever the other evidence says.
Why networks save numbers
- A full joint distribution over 10 binary variables needs $2^{10} - 1 = 1023$ numbers. In a network where each variable has at most 2 parents, each table needs at most $2^2 = 4$ numbers, so $10 \times 4 = \mathbf{40}$ in total.
- Each missing edge claims a conditional independence 条件独立, and those claims are what make inference and learning possible with little data.
Numbers needed for a full joint distribution over 10 binary variables?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
$2^{10} - 1$; the last probability follows from the rest.
A missing edge in a Bayesian network claims a conditional independence.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Each variable is independent of its non-descendants given its parents.
Worked example: smoothing a zero
- "Prize" appeared in 0 of 40 ham emails. Without smoothing, $P(\text{prize} \mid \text{ham}) = 0$, and one occurrence makes any email certain spam.
- Laplace smoothing 拉普拉斯平滑 with two outcomes (present or absent) gives $(0 + 1)/(40 + 2) = \mathbf{0.024}$: small, but not impossible. The more data there is, the less the added counts matter.
A word seen in 0 of 40 ham emails, Laplace smoothing over two outcomes: estimate (three decimals)?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
$1/42 = 0.024$.
Marks that slip away
- Leaving out the normaliser. $P(S \mid C)$ needs the division by $P(C) = 0.2205$.
- Swapping the conditionals. $P(C \mid S) = 0.49$ is not $P(S \mid C) = 0.667$.
- Zero counts in naive Bayes 朴素贝叶斯. One unseen word wipes out all the other evidence; add-one smoothing prevents it.
Recap
- A Bayesian network 贝叶斯网络 is a directed acyclic graph with conditional tables; inference multiplies and normalises.
- Course network: $P(S \mid C) = 0.667$ when $P(S) = 0.3$, but only $0.126$ when $P(S) = 0.03$.
- Never leave out the normaliser, and never swap $P(C \mid S)$ for $P(S \mid C)$.
ما المشكلة؟ لا يرى ذلك سوى فريق الموقع.