COMP5318 Practice Exam 2 整卷逐题解析
COMP5318 Practice Exam 2 整卷逐题解析
课程:COMP4318/COMP5318 — Machine Learning and Data Mining 材料:
Exam Prep/COMP5318_Practice_Exam_2.pdf(题目,20 页)+COMP5318_Practice_Exam_2_Solutions.pdf(官方答案与评分指引,10 页) 答案来源:所有答案都按官方 Solutions 给出。「为什么其他选项错」和知识点归属是我补充的。 形式:与 Paper 1 相同——2 小时,闭卷,Part A 30 × 2 分,Part B 4 × 10 分。第一套见 Practice Exam 1 解析。
答案速查(官方)
| Q | 答 | Q | 答 | Q | 答 | Q | 答 | Q | 答 |
|---|---|---|---|---|---|---|---|---|---|
| 1 | D | 7 | B | 13 | C | 19 | B | 25 | B |
| 2 | B | 8 | D | 14 | C | 20 | C | 26 | C |
| 3 | D | 9 | D | 15 | B | 21 | D | 27 | A |
| 4 | B | 10 | C | 16 | C | 22 | A | 28 | A |
| 5 | A | 11 | A | 17 | D | 23 | A | 29 | D |
| 6 | C | 12 | A | 18 | B | 24 | B | 30 | C |
Part A:选择题
Q1 按购买特征把无标签客户分组 → D 无监督聚类
Original question (English) · [2 marks] An analyst groups unlabelled customer records by similarities in their purchasing features. Which task best describes this?
- A. Reinforcement learning.
- B. Supervised classification.
- C. Supervised regression.
- D. Unsupervised clustering.
没有目标标签,目的是发现分组。A 需要奖励信号;B、C 需要标签。
English answer (Official): D — Learning tasks. There is no supplied target label. The objective is to discover groups from the input features.
Q2 kNN 的预测代价 → B
Original question (English) · [2 marks] A standard k-NN classifier stores its training observations. Which statement about prediction is most appropriate?
- A. Training removes the need to store any examples or index.
- B. Prediction may require many distance calculations because the stored observations are consulted.
- C. Increasing the training set always reduces prediction cost.
- D. Prediction uses only one fitted intercept and slope.
- 答案 B:kNN 是基于实例的「懒惰」学习器,预测时要查询存储的样本,可能需要大量距离计算(索引结构如 KD 树可缓解)。
- A 恰恰相反,必须保存样本;C 训练集越大预测越贵;D 是线性回归。
- 知识点:W02 kNN 计算复杂度
English answer (Official): B — k-NN complexity. k-NN is an instance-based method. Prediction searches stored examples, so its cost can be substantial; indexing methods can help.
Q3 曼哈顿与欧氏距离 → D(7 和 5)
Original question (English) · [2 marks] For x = (1, 4) and y = (4, 0), what are their Manhattan and Euclidean distances, respectively?
- A. 7 and 25.
- B. 25 and 7.
- C. 5 and 7.
- D. 7 and 5.
- A 的 25 是没开方的平方欧氏距离;B 顺序反了。
- 知识点:W02 数值属性的距离
English answer (Official): D — Distance measures. Absolute coordinate differences are 3 and 4. Manhattan distance is 3+4 = 7, and Euclidean distance is √(3²+4²) = 5.
Q4 1R 的最终模型 → B
Original question (English) · [2 marks] A 1R classifier is fitted using several candidate categorical attributes. What distinguishes its final model?
- A. It combines all attributes into a deep decision tree.
- B. It uses one selected attribute to form a set of simple prediction rules.
- C. It predicts a separate class for every distinct full feature vector.
- D. It requires exactly one training observation per class.
- 答案 B:1R 对每个属性各建一套「一个取值 → 一个类」的规则,选错误率最低的那一个属性的规则集。
- A 是决策树;C 是查表/记忆;D 无此要求。
- 知识点:规则学习(1R / PRISM),周总结里没有单独成节,可对照 W05 决策树(1R 相当于深度为 1 的树)。
English answer (Official): B — 1R. 1R evaluates simple rules based on individual attributes and selects one attribute’s rule set, rather than building conjunctions across many attributes.
Q5 逻辑回归输出 0.83 → A
Original question (English) · [2 marks] A logistic-regression model returns 0.83 for an observation. Under a threshold of 0.5, what is the appropriate interpretation?
- A. It predicts the positive class and estimates its probability as 0.83.
- B. It predicts the negative class because the probability is below one.
- C. It predicts a numeric target of exactly 0.83 using ordinary least squares.
- D. It guarantees the observation is positive.
- 答案 A:输出是正类的估计概率;0.83 ≥ 0.5 → 预测正类。
- B 阈值是 0.5 不是 1;C 逻辑回归用最大似然,不是 OLS,输出也不是数值目标;D 概率 ≠ 保证。
- 知识点:W03 逻辑回归
English answer (Official): A — Logistic regression. The output is an estimated probability for the positive class. Because 0.83 exceeds 0.5, the assigned label is positive; this is not a guarantee of correctness.
Q6 Ridge 增大惩罚强度 → C 对大系数惩罚更重
Original question (English) · [2 marks] In ridge regression, the penalty strength is increased while the input features and training data stay fixed. What is the direct effect on the optimisation objective?
- A. The training set automatically receives additional examples.
- B. Validation labels are added to the training loss.
- C. Large coefficient magnitudes receive a stronger penalty.
- D. The intercept must become equal to the number of features.
Ridge 目标
知识点:W03 正则化
English answer (Official): C — Ridge regularisation. Ridge adds a scaled sum of squared coefficients to the loss. Increasing that scale strengthens the pressure toward smaller coefficients.
Q7 MAE 与 MSE → B(4/3 和 2)
Original question (English) · [2 marks] For three observations, the true targets are (2, 4, 8) and the predictions are (1, 6, 7). What are MAE and MSE, respectively?
- A. MAE = 0; MSE = 0.
- B. MAE = 4/3; MSE = 2.
- C. MAE = 4; MSE = 6.
- D. MAE = 2; MSE = 4/3.
残差
- C 是没除以 n 的总和;D 两者颠倒。
- 知识点:W03 三类误差
English answer (Official): B — Regression error. Residuals are (1,-2,1). The absolute-error sum is 4 and squared-error sum is 6, giving MAE = 4/3 and MSE = 2.
Q8 朴素贝叶斯的分解假设 → D 给定类别时各特征似然相乘
Original question (English) · [2 marks] Which factorisation is assumed by Naive Bayes when scoring an observation with multiple input features?
- A. The input features must have equal numeric values.
- B. The class posterior is identical to the class prior for every observation.
- C. The features must be independent of the class itself.
- D. The feature likelihoods multiply conditional on the class.
- C 是常见陷阱:假设的是给定类别下特征之间独立,不是特征与类别独立(那样分类器就没用了);B 同理。
- 知识点:W04 朴素贝叶斯的两条假设
English answer (Official): D — Naive Bayes assumption. Naive Bayes assumes conditional independence of features given the class, so the joint class-conditional likelihood is written as a product.
Q9 五折交叉验证中标准化在哪拟合 → D
Original question (English) · [2 marks] During five-fold cross-validation for choosing hyperparameters, where should a standard scaler be fitted for a particular fold?
- A. On all five folds together before any split.
- B. Only on that fold’s validation portion.
- C. On the reserved final test set.
- D. Only on that fold’s training portion, before transforming its validation portion.
- 答案
D:只在该折的训练部分上拟合,再变换该折的验证部分。用
Pipeline可以自动保证。 - A 在切分前用全部数据拟合 → 验证折信息泄漏;B、C 同样泄漏。
- 知识点:W04 评估流程、W02 标准化
English answer (Official): D — Cross-validation. Each fold must reproduce the full training procedure without using its validation data to fit preprocessing. A pipeline keeps this separation clear.
Q10 Recall 与 F1 → C
Original question (English) · [2 marks] For the positive class, TP = 18, FN = 6 and FP = 12. What are recall and F1, respectively?
- A. Recall 0.60; F1 approximately 0.667.
- B. Recall 0.75; F1 0.750.
- C. Recall 0.75; F1 approximately 0.667.
- D. Recall 0.60; F1 0.750.
- A、D 把 recall 算成了 precision 的 0.60;B 的 F1 = 0.75 是误把 F1 当成 recall。
- 知识点:W04 性能度量
English answer (Official): C — Classification metrics. Recall = 18/24 = 0.75. F1 = 2×18/(36+12+6) = 36/54 = 2/3 ≈ 0.667.
Q11 树路径对应的规则 → A(AND)
Original question (English) · [2 marks] A tree path goes to the Yes leaf only when Colour = green and Size = small. Which rule expresses that path?
- A. If Colour = green AND Size = small, predict Yes.
- B. If Size = small, predict Yes regardless of Colour.
- C. If Colour is not green AND Size = small, predict Yes.
- D. If Colour = green OR Size = small, predict Yes.
一条根到叶的路径上所有测试都要满足 → 合取。D 的 OR 会把路径之外的样本也包进来。
知识点:W05 决策树
English answer (Official): A — Decision-tree rules. All tests along one root-to-leaf path must be satisfied, so they form a conjunction. An OR would incorrectly include observations outside the path.
Q12 随机森林额外的随机化 → A 每次分裂只在随机特征子集里搜索
Original question (English) · [2 marks] A random forest uses bootstrap samples. What additional randomisation commonly helps reduce similarity between its trees?
- A. Search a random subset of candidate features at each split.
- B. Restrict every tree to a single identical feature chosen once for the whole forest.
- C. Choose the final prediction using the training labels of the test observations.
- D. Give all trees identical fixed splits.
降低树之间的相关性,避免强特征主导每棵树。B、D 让树更相似;C 是泄漏。
图解
flowchart LR
T["训练集"] --> b1["bootstrap 样本 1"] --> t1["树 1:每次分裂只看随机 k 个特征"]
T --> b2["bootstrap 样本 2"] --> t2["树 2:每次分裂只看随机 k 个特征"]
T --> b3["bootstrap 样本 M"] --> t3["树 M:每次分裂只看随机 k 个特征"]
t1 --> V["多数投票"]
t2 --> V
t3 --> V
English answer (Official): A — Random forests. Random feature subsets at each split reduce the tendency for the same strong predictors to dominate every tree.
Q13 AdaBoost 权重调整 → C 被错分样本的相对权重增大
Original question (English) · [2 marks] After a weak classifier is trained in AdaBoost, how are the relative example weights adjusted for the next stage?
- A. Only correctly classified examples remain eligible for training.
- B. All example weights are permanently set to zero.
- C. Misclassified examples gain influence relative to correctly classified examples.
- D. Weights are determined by input magnitude without reference to errors.
A 正确样本仍参与训练,只是权重降低;B 不会清零;D 权重由错误决定。
知识点:W05 Boosting
图解
flowchart LR
C1["弱分类器 1"] --> E["分对样本权重 × e/(1−e),再归一化"]
E --> W["错分样本相对权重 ↑"]
W --> C2["弱分类器 2 更关注难样本"]
C2 --> F["最终:按准确率加权投票"]
English answer (Official): C — AdaBoost. AdaBoost increases relative emphasis on mistakes, encouraging the next learner to address observations the current ensemble finds difficult.
Q14 多项式核 → C 49
Original question (English) · [2 marks] For x = (1, 2) and y = (3, 1), calculate K(x,y) for the kernel K(x,y) = (xᵀy + 2)².
- A. 29.
- B. 7.
- C. 49.
- D. 25.
知识点:W06 核技巧
English answer (Official): C — SVM kernels. The dot product is 1×3 + 2×1 = 5. Therefore K = (5+2)² = 49.
Q15 软间隔 SVM 的 C 变大 → B 对间隔违例惩罚更重
Original question (English) · [2 marks] A soft-margin SVM uses a larger value of C, with the same training data and kernel. What changes in the objective?
- A. The kernel degree automatically increases.
- B. Margin violations are penalised more strongly relative to the preference for a wide margin.
- C. Margin violations are no longer allowed under any circumstances.
- D. The training data are standardised automatically.
C 权衡「宽间隔」与「违例惩罚」。C 很大时接近硬间隔,但只要 C 有限就不是绝对禁止违例(所以 C 选项错)。A、D 无关。
知识点:W06 软间隔 SVM
English answer (Official): B — Soft-margin SVM. C controls the trade-off between margin size and violation penalties. A larger finite C increases the penalty but does not generally prohibit all violations.
Q16 「PCA 就是挑几列原始特征」的纠正 → C
Original question (English) · [2 marks] A student says that PCA simply chooses a subset of the original feature columns. What is the most accurate correction?
- A. PCA deletes observations while preserving every original coordinate.
- B. Each component must equal one original feature without scaling.
- C. Principal components generally define new coordinates formed from linear combinations of the features.
- D. PCA uses the supplied class labels to rank original columns.
主成分是原始特征的线性组合,定义了新坐标;降维是在新坐标系里保留前几个方向。A 不删样本;B 一般不等于单个原始特征;D PCA 不用标签。
知识点:W06 PCA 的核心思想
English answer (Official): C — PCA coordinates. PCA performs a linear change of coordinates. Dimensionality reduction then retains selected directions in that transformed coordinate system.
Q17 保留至少 90% 方差 → D(两个,90%)
Original question (English) · [2 marks] A dataset has exactly three principal components, with variances 12, 6 and 2. What is the smallest number of leading components that retain at least 90% of the total variance?
- A. Two components, retaining 80%.
- B. One component, retaining 60%.
- C. Three components, retaining 100%.
- D. Two components, retaining 90%.
总和 20;一个 60%,两个
知识点:W06 选几个主成分
English answer (Official): D — PCA retained variance. The total is 20. One component retains 12/20 = 60%; two retain 18/20 = 90%, which meets the threshold exactly.
Q18 小批量梯度下降为什么更「吵」 → B 每次只用一部分样本估计梯度
Original question (English) · [2 marks] Why can minibatch gradient descent have noisier updates than full-batch gradient descent?
- A. It guarantees larger generalisation error on every possible dataset.
- B. Each update estimates the gradient using only a subset of training examples.
- C. It has no objective function to minimise.
- D. It changes the labels randomly before every update.
A 不保证;C 有目标函数;D 不改标签。
知识点:W07 反向传播与训练
English answer (Official): B — Gradient methods. A minibatch gradient varies with the sampled examples. Full-batch descent uses the gradient averaged over the complete training set.
Q19 梯度下降一步 → B (0.2, −0.8)
Original question (English) · [2 marks] At w = (0.5, -1.0), the loss gradient is (3, -2). A gradient-descent step uses learning rate 0.1. What is the new w?
- A. (0.8, -1.2).
- B. (0.2, -0.8).
- C. (0.2, -1.2).
- D. (-2.5, 1.0).
- A 是加梯度(往上爬);C 第二维符号弄错;D 用了学习率 1。
- 知识点:W07 梯度下降
English answer (Official): B — Gradient descent. Subtract 0.1 times the gradient: (0.5,-1) - (0.3,-0.2) = (0.2,-0.8).
Q20 2×2 最大池化输出 → C 窗口内的最大激活
Original question (English) · [2 marks] For standard 2 × 2 max pooling, what value is passed on from each pooling window?
- A. The smallest activation in the complete image.
- B. A newly learned bias independent of the input.
- C. The largest activation in that window.
- D. The sum of all learned convolution weights.
池化本身没有可训练权重(B、D 错);A 是整幅图的最小值,不对。
知识点:W08 池化层
English answer (Official): C — CNN pooling. Max pooling selects the maximum within each spatial window. The standard pooling operation itself has no trainable weights.
Q21 为什么用 LSTM → D 门控状态更新有助于长时间保持信息与梯度传递
Original question (English) · [2 marks] Which property motivates the use of LSTMs rather than a simple RNN for some long-sequence tasks?
- A. LSTMs require a different unshared recurrent matrix at every time step.
- B. LSTMs make the ordering of all inputs irrelevant.
- C. LSTMs eliminate the need to train any weights.
- D. Gated state updates can help retain information and support gradient flow over longer intervals.
A 循环权重仍共享;B 顺序依然重要;C 当然要训练。门控有助于但不保证完美记忆。
知识点:W08 LSTM
English answer (Official): D — LSTM motivation. LSTM gates regulate what is stored, retained and exposed. They can help with long-range dependencies, although they do not guarantee perfect memory.
Q22 卷积 + 池化后的空间尺寸 → A 8×8
Original question (English) · [2 marks] An 18 × 18 input passes through a 3 × 3 convolution with stride 1 and no padding, then 2 × 2 max pooling with stride 2 and no padding. What is the final spatial size?
- A. 8 × 8.
- B. 9 × 9.
- C. 7 × 7.
- D. 16 × 16.
B 的 9 是用 18/2;D 只算了卷积那一步。
知识点:W08 卷积层与池化层
图解
flowchart LR
I["18×18"] -->|"3×3 卷积, s=1, p=0<br/>(18−3)/1+1"| C["16×16"]
C -->|"2×2 池化, s=2<br/>(16−2)/2+1"| P["8×8"]
English answer (Official): A — CNN output size. The convolution gives (18-3)/1 + 1 = 16 per dimension. Pooling gives (16-2)/2 + 1 = 8 per dimension.
Q23 Dropout 推断 → A 用全部单元,缩放与训练约定一致
Original question (English) · [2 marks] A network was trained using dropout. Which statement about standard inference is appropriate?
- A. Use all units, with scaling handled consistently with the dropout training convention.
- B. Continue disabling units without accounting for the training convention.
- C. Delete every unit that was ever dropped during training.
- D. Reset all weights to their initial random values.
- 「inverted dropout」在训练时已除以保留率,推断时不需再缩放;原始约定则在推断时把权重乘以保留率。
- B 推断时不再随机丢弃;C、D 荒谬。
- 知识点:W07 Dropout
English answer (Official): A — Dropout at inference. Standard inference uses the full network. With inverted dropout, scaling is already applied during training; under the original convention, it is applied at inference.
Q24 想要每个分量的隶属概率 → B GMM
Original question (English) · [2 marks] An analyst wants a probability of membership in each component, rather than only one hard cluster assignment. Which model directly supplies this?
- A. A single fixed cut of a dendrogram.
- B. A Gaussian mixture model.
- C. A nearest-centroid label without probability normalisation.
- D. Standard K-means assignments.
GMM 给出后验责任度(软分配);K-means、最近质心、树状图切割都是硬分配。
知识点:W09 GMM
English answer (Official): B — GMM versus K-means. A GMM estimates posterior responsibilities for its components. Standard K-means and dendrogram cuts return hard assignments.
Q25 单链与平均链 → B(4 和 6)
Original question (English) · [2 marks] Clusters A = {0, 2} and B = {6, 8} contain one-dimensional points. With absolute point-to-point distance, what are single-link and average-link distances?
- A. Single-link 4; average-link 8.
- B. Single-link 4; average-link 6.
- C. Single-link 8; average-link 6.
- D. Single-link 6; average-link 4.
A = {0, 2},B = {6, 8},跨簇距离:0–6 = 6,0–8 = 8,2–6 = 4,2–8 = 6。
- 单链 = 最小值 4;平均链 =
;完全链 = 8。 - A 把完全链当平均链;C 把完全链当单链。
- 知识点:W09 层次聚类
图解
flowchart LR
a0["A: 0"] ---|6| b6["B: 6"]
a0 ---|8| b8["B: 8"]
a2["A: 2"] ---|4| b6
a2 ---|6| b8
b6 --> R["single = min = 4<br/>average = 24/4 = 6<br/>complete = max = 8"]
English answer (Official): B — Hierarchical linkage. The four cross-cluster distances are 6, 8, 4 and 6. Their minimum is 4, and their mean is 24/4 = 6.
Q26 从观测序列估计转移与发射参数 → C 模型学习(如 EM / Baum-Welch)
Original question (English) · [2 marks] An HMM’s transition and emission parameters are unknown and must be estimated from observed sequences. Which task is this?
- A. Decoding with a fixed model using Viterbi.
- B. Evaluation with fixed parameters using the Forward algorithm.
- C. Model learning, for example using an EM procedure.
- D. Dimensionality reduction using principal components.
A 解码(参数已知求路径);B 评估(参数已知求似然);D 无关。
知识点:W11 HMM 三个问题
English answer (Official): C — HMM learning. Learning estimates model parameters. Evaluation calculates sequence likelihood under a fixed model; decoding finds a hidden-state path.
Q27 Viterbi 一步 → A 0.070
Original question (English) · [2 marks] At time 1, V₁(A) = 0.3 and V₁(B) = 0.2. Transitions into B are P(B|A) = 0.4 and P(B|B) = 0.7. The next observation has emission probability 0.5 in B. What is V₂(B)?
- A. 0.070.
- B. 0.130.
- C. 0.060.
- D. 0.140.
- B 0.130 是把两条路径相加再乘 0.5(那是 Forward 的做法);C 0.060 取了较小的那条;D 0.140 忘了乘发射概率。
- 知识点:W11 Viterbi
图解
flowchart LR
A1["V₁(A) = 0.3"] -->|"×0.4 = 0.12"| B2["V₂(B) = 0.5 × max(0.12, 0.14) = 0.070"]
B1["V₁(B) = 0.2"] -->|"×0.7 = 0.14 ✓ 最大"| B2
English answer (Official): A — Viterbi update. Candidate predecessor scores are 0.3×0.4 = 0.12 and 0.2×0.7 = 0.14. Viterbi takes the maximum, then multiplies by 0.5: 0.070.
Q28 减小折扣因子 → A 远期奖励相对即时奖励的权重下降
Original question (English) · [2 marks] In an RL return, the discount factor is reduced while rewards and transitions stay the same. What is the direct effect?
- A. Later rewards receive less weight relative to immediate rewards.
- B. Every possible action acquires the same value.
- C. The environment becomes deterministic.
- D. Observed immediate rewards change their numerical values.
γ 只改变回报中各期奖励的加权,不改变环境的奖励值或转移(C、D 错),也不会让动作价值都相等(B 错)。
知识点:W12 折扣回报
English answer (Official): A — Discounting. Discounting changes the weighting of future rewards in the return, not the environment’s rewards or transition probabilities.
Q29 为什么图像状态用 DQN 而非 Q 表 → D 共享参数的函数可以在巨大输入空间上近似价值
Original question (English) · [2 marks] Why can a deep Q-network be preferable to a Q-table for image-based states?
- A. It stores one independent table row for every possible image.
- B. It guarantees exact optimal values before any training.
- C. It removes the need for observations from the environment.
- D. A shared parameterised function can approximate values over a very large input space.
A 正是 Q 表做不到的事;B 不保证;C 仍需环境交互。
知识点:W12 函数逼近与 DQN
English answer (Official): D — Value function approximation. A DQN uses shared network parameters to estimate state-action values. This avoids explicitly storing a separate value for every possible image.
Q30 期望回溯动作价值 → C 2.60
Original question (English) · [2 marks] An action has two outcomes. With probability 0.4, it gives reward 2 and reaches a state of optimal value 6. Otherwise it gives reward 0 and reaches a state of optimal value 2. For γ = 0.5, what is the expected backed-up action value?
- A. 3.00.
- B. 1.40.
- C. 2.60.
- D. 5.00.
两个结果的回溯值:
D 5.00 只取了好的那个结果;A、B 都不是「先对每个结果算
知识点:W12 Bellman 方程
图解
flowchart LR
S(("动作 a")) -->|"p = 0.4"| O1["r = 2, V(s′) = 6<br/>2 + 0.5×6 = 5"]
S -->|"p = 0.6"| O2["r = 0, V(s′) = 2<br/>0 + 0.5×2 = 1"]
O1 --> E["期望 = 0.4×5 + 0.6×1 = 2.6"]
O2 --> E
English answer (Official): C — Expected action value. The backed-up values are 2+0.5×6 = 5 and 0+0.5×2 = 1. Their expectation is 0.4×5 + 0.6×1 = 2.6.
Part B:计算题
Q31 朴素贝叶斯后验(10 分)
Original question (English) · Question 31. Naive Bayes posterior probabilities [10 marks]
A Naive Bayes classifier has classes Yes and No. An observation has F₁ = present and F₂ = present. Assume the two features are conditionally independent given the class. Yes: prior 0.4, P(F₁=present|Yes) = 0.75, P(F₂=present|Yes) = 0.50. No: prior 0.6, P(F₁=present|No) = 0.25, P(F₂=present|No) = 0.50.
- [5 marks] Calculate the two unnormalised class scores.
- [5 marks] Calculate the posterior probability of each class, and give the predicted class using the larger posterior. Round probabilities to three decimal places.
| 类 | 先验 | P(F₁=present | c) | P(F₂=present | c) |
|---|---|---|---|
| Yes | 0.4 | 0.75 | 0.50 |
| No | 0.6 | 0.25 | 0.50 |
(a) 未归一化得分(5 分)
(b) 后验与预测(5 分) 归一化常数
预测 Yes。注意 F₂ 在两类下似然相同(都是 0.5),对判别没有贡献,结果完全由先验和 F₁ 决定。
评分:(a) 包含先验和两个似然 1 分 + 每个得分 2 分;(b) 归一化 1 分、两个后验 3 分、预测 1 分。
知识点:W04 朴素贝叶斯算例
图解
flowchart LR
Y["Yes:先验 0.4<br/>× 0.75(F₁)× 0.5(F₂)"] --> sY["s_Yes = 0.15"]
N["No:先验 0.6<br/>× 0.25(F₁)× 0.5(F₂)"] --> sN["s_No = 0.075"]
sY --> Z["和 = 0.225"]
sN --> Z
Z --> P["P(Yes) = 0.667,P(No) = 0.333 → 预测 Yes"]
English answer (Official)
s_Yes = 0.4 × 0.75 × 0.50 = 0.15; s_No = 0.6 × 0.25 × 0.50 = 0.075.
Evidence = 0.15 + 0.075 = 0.225. P(Yes | F₁,F₂) = 0.15/0.225 = 2/3 ≈ 0.667; P(No | F₁,F₂) = 0.075/0.225 = 1/3 ≈ 0.333. Predict Yes.
Q32 最小二乘拟合与 MSE(10 分)
Original question (English) · Question 32. Least-squares fit and prediction error [10 marks]
Fit a simple least-squares line to the observations (x, y) = (1, 2), (2, 2), (3, 5). The mean of x is 2 and the mean of y is 3.
- [5 marks] Calculate Sxy, Sxx, the slope b₁ and intercept b₀.
- [5 marks] Calculate the fitted prediction for each observation and the training MSE.
数据
(a)(5 分) 中心化后
(b)(5 分)
评分:(a) 两个和 2 分 + 斜率截距 3 分;(b) 预测 2 分、平方误差 2 分、取平均 1 分。
知识点:W03 最小二乘法
English answer (Official)
Centred x = (−1, 0, 1), centred y = (−1, −1, 2). Sxy = (−1)(−1) + 0(−1) + 1(2) = 3; Sxx = 1 + 0 + 1 = 2. b₁ = 3/2 = 1.5; b₀ = 3 − 1.5×2 = 0.
ŷ = 1.5x gives predictions (1.5, 3.0, 4.5). Residuals y − ŷ = (0.5, −1.0, 0.5); squared-error sum = 0.25 + 1 + 0.25 = 1.5. MSE = 1.5/3 = 0.5.
Q33 凝聚式层次聚类(10 分)
Original question (English) · Question 33. Agglomerative clustering and linkage [10 marks]
Four one-dimensional observations are A = 0, B = 3, C = 8 and D = 10. Begin with four singleton clusters and use absolute point-to-point distance. There are no ties in the first two merge decisions.
- [5 marks] Using complete linkage, give the first merge, the distances from the merged cluster to each remaining singleton, and the second merge.
- [5 marks] For the two clusters remaining after those merges, calculate their single-link and complete-link distances. Explain which pairwise distances determine them.
A = 0,B = 3,C = 8,D = 10。两两距离:AB = 3,AC = 8,AD = 10,BC = 5,BD = 7,CD = 2。
(a) 完全链(5 分)
- 最小距离是 CD = 2 → 第一次合并 {C, D}。
- 完全链取最大值:
, 。 - 当前距离 AB = 3、{CD}–B = 7、{CD}–A = 10 → 第二次合并 {A, B}(距离 3)。
(b) 剩下两个簇的单链与完全链距离(5 分)
{A, B} 与 {C, D} 的跨簇距离:8、10、5、7。
- 单链 = 最小值 5,由 B 和 C 决定(两簇最近的一对点);
- 完全链 = 最大值 10,由 A 和 D 决定(两簇最远的一对点)。
评分:(a) 第一次合并 1 分、更新距离 2 分、第二次合并 2 分;(b) 每个距离 2 分 + 指出决定点对 1 分。
知识点:W09 层次聚类与链接方式
图解
flowchart BT
A["A = 0"] --> AB["{A,B}<br/>第 2 次合并, 高度 3"]
B["B = 3"] --> AB
C["C = 8"] --> CD["{C,D}<br/>第 1 次合并, 高度 2"]
D["D = 10"] --> CD
AB --> ALL["{A,B,C,D}<br/>complete 高度 10(single 是 5)"]
CD --> ALL
English answer (Official)
Pairwise distances: AB = 3, AC = 8, AD = 10, BC = 5, BD = 7, CD = 2. First merge: {C, D} at distance 2. Complete-link distances: d({C,D}, A) = max(8, 10) = 10; d({C,D}, B) = max(5, 7) = 7; d(A, B) = 3 is the smallest, so the second merge is {A, B} at distance 3.
Cross-cluster distances between {A,B} and {C,D} are 8, 10, 5, 7. Single link = min = 5, set by the pair B–C; complete link = max = 10, set by the pair A–D.
Q34 神经网络前向传播(10 分)
Original question (English) · Question 34. Neural network forward pass [10 marks]
A network receives x₁ = 2 and x₂ = −1. Its two hidden units use ReLU and its output uses a sigmoid. The equations (an image in the paper) are u_A = x₁ + 2x₂ − 1, u_B = 2x₁ − x₂ − 2, z = 3h_A + h_B − 1, output = σ(z). Predict class 1 when the output probability is at least 0.5; otherwise class 0. Use e ≈ 2.718 if needed.
- [5 marks] Calculate both hidden pre-activations u_A and u_B, then the hidden activations h_A and h_B.
- [5 marks] Calculate z, the output probability and the predicted class. Then replace only unit A's ReLU by the identity activation h_A = u_A. Give the new probability and class. Round probabilities to three decimal places.
题目里的方程是图片,原式为:
输入
(a)(5 分)
(b)(5 分)
- 两个都是 ReLU:
, → 类 1。 - 只把 A 换成恒等:
, , , → 类 0,分类翻转。
评分:与 Paper 1 的 Q32 相同(预激活 2、激活 3;原输出 2、修改后 3)。
知识点:W07 前向传播
图解
flowchart LR
x1(("x₁ = 2")) --> uA["u_A = 2 + 2×(−1) − 1 = −1<br/>ReLU → h_A = 0"]
x2(("x₂ = −1")) --> uA
x1 --> uB["u_B = 4 + 1 − 2 = 3<br/>ReLU → h_B = 3"]
x2 --> uB
uA -->|"×3"| z["z = 3×0 + 3 − 1 = 2"]
uB -->|"×1"| z
z --> o["σ(2) ≈ 0.881 → 类 1"]
uA -.->|"A 改恒等: h_A = −1"| z2["z = −3 + 3 − 1 = −1<br/>σ(−1) ≈ 0.269 → 类 0"]
English answer (Official)
u_A = 2 + 2×(−1) − 1 = −1; u_B = 2×2 − (−1) − 2 = 3. ReLU gives h_A = 0, h_B = 3.
With both ReLUs: z = 3×0 + 3 − 1 = 2, output = 1/(1 + e⁻²) ≈ 0.881 → class 1. With the identity at A only: h_A = −1, h_B = 3, z = 3×(−1) + 3 − 1 = −1, output ≈ 0.269 → class 0. The class changes.
两套卷对比
| 题型 | Paper 1 | Paper 2 |
|---|---|---|
| 距离 / kNN | 加权投票 | 曼哈顿 vs 欧氏、预测代价 |
| 规则学习 | PRISM 加条件 | 1R |
| 回归误差 | MAE 抗离群 | MAE/MSE 计算 |
| 评估 | Precision/Recall | Recall/F1;CV 中的标准化 |
| SVM | 间隔 2/‖w‖、核技巧 | 多项式核计算、软间隔 C |
| PCA | 85% 方差 | 90% 方差、新坐标 |
| HMM | Viterbi 定义、两步转移 | 学习问题、Viterbi 一步 |
| RL | 经验回放、目标网络、Q 更新 | 折扣因子、DQN、期望回溯 |
| Part B | 信息增益 / 前向传播 / K-means / HMM Forward | 朴素贝叶斯 / 最小二乘 / 层次聚类 / 前向传播 |
规律:Part B 的「前向传播 + 把一个 ReLU 换成恒等」两套都考,几乎可以确定是固定题型;其他三题在 {信息增益、K-means、HMM Forward、朴素贝叶斯、最小二乘、层次聚类} 里轮换,都值得练熟。