ML Basics Quick Checks: Bayes, Forward Pass, KNN and Attention
Problem statement
A timed online assessment opens with a handful of quick multiple-choice and numeric checks on ML basics before its coding questions. Work each item quickly but show enough reasoning that a slip would be caught.
Bayes. 1% of transactions on a payments platform are fraudulent. A fraud detector flags 95% of fraudulent transactions and 4% of legitimate ones.
Forward pass. A tiny network takes two inputs $(x_1, x_2)$. Hidden unit 1 computes $h_1 = \text{ReLU}(1 \cdot x_1 + 2 \cdot x_2 + 0.5)$, hidden unit 2 computes $h_2 = \text{ReLU}(-1 \cdot x_1 + 1 \cdot x_2 + 1)$, and the output is $y = \sigma(3 h_1 - 2 h_2 - 1)$, where $\sigma$ is the sigmoid.
Parameter count. A fully connected classifier maps 10 input features to a hidden layer of 64 units, then a hidden layer of 32 units, then 3 output logits. Every layer has a bias.
KNN and transformers. Two concept checks follow.
- A transaction is flagged by the detector. What is the probability that it is fraudulent?
- A second detector with the same rates, whose decisions are independent of the first detector's given the true class, also flags it. What is the probability now?
- Compute the network's output $y$ for the input $(x_1, x_2) = (2, -1)$. Which parameters receive zero gradient from this example?
- How many trainable parameters does the 10 -> 64 -> 32 -> 3 classifier have?
- KNN check: with raw income (dollars) and age (years) as features, which statement about a k-nearest-neighbor classifier is true?
- Transformer check: which statement about self-attention is true?
Show hint
For the Bayes items, what fraction of all flags come from legitimate transactions once you account for how rare fraud is?
Relevant roles: ML Engineer, Data Scientist and Applied Scientist.
Related free problems
- Gated AttentionML CodingMedium