S14 · Problem set 4
Problem set 4: linear discriminants and Fisher's criterion, the perceptron, logistic regression, Gaussian and naive Bayes classifiers, and evaluating models
These problems cover lessons 15 to 17, 20 and 21: anomaly detection and base rates, distances to decision boundaries, Fisher's direction and separation with correlated features, perceptron updates and mistake bounds, sigmoids, log-odds, softmax losses and cross-entropy gradients, the logistic posterior of Gaussian classes, naive Bayes evidence, and precision, recall, AUC, the error bars on a test score and McNemar's test for comparing two classifiers.
Check
A linear discriminant with w = (2, 1) and = −3.
(a)
Signed distance of (4, 2)?
(b)
Distance of the boundary from the origin?
Check
Classes whose means differ by (1, 2), with a diagonal within-class scatter of variances 2 and 8.
(a)
Fisher's direction, from the first axis?
(b)
Its separation J?
(c)
J along the line joining the means?
Check
A perceptron with w = (1, 2), rate 0.25, updating on a misclassified (3, 2) with target 1; separately, data of radius 3 and margin 0.2.
(a)
New first component?
(b)
Mistake bound?
Check
A logistic model with = −5 and = 0.5.
(a)
Probability at x = 4?
(b)
Decision boundary?
(c)
Odds ratio per unit of x?
Check
The same kind of model ( = −3, = 0.5) trains on an example at x = 3 with target 1.
(a)
Gradient with respect to ?
(b)
Cross-entropy loss for this example?
Check
Log-odds and probabilities.
(a)
Log-odds of 0.6?
(b)
Change in activation to move a prediction from 0.05 to 0.6?
Check
Gaussian classes with means 1 and −1, shared variance 1.5², class 1's prior 0.8.
(a)
Weight on x?
(b)
Offset ?
(c)
Posterior of class 1 at x = 0.5?
Check
Naive Bayes with prior 0.05 and three features whose likelihood ratios are 3, 0.6 and 4.
(a)
Posterior log-odds?
(b)
Posterior probability?
Check
Two-class classifiers in 8 dimensions.
(a)
Shared-covariance Gaussian parameters?
(b)
Separate covariances?
(c)
Logistic regression?
Check
A confusion matrix: TP = 25, FP = 4, FN = 30, TN = 900.
(a)
Precision?
(b)
Recall?
(c)
F1?
(d)
Accuracy?
Check
A test with sensitivity 0.85 and specificity 0.9 at prevalence 0.05; separately, Gaussian scores 2.5 standard deviations apart.
(a)
Precision?
(b)
AUC?
Check
A test accuracy of 0.75 on 200 examples; separately, 10-fold cross-validation on 2000 examples.
(a)
Standard error?
(b)
Training examples per fit?
Check
Two classes share a within-class covariance with a = 2, b = 1, c = −0.8; their means differ by (2, 1).
(a)
What separation does Fisher's direction achieve?
(b)
And projecting onto the mean difference itself?
Check
A three-class softmax gives activations 1, 0 and 0.5; the true class is the second.
(a)
What probability does it give the true class?
(b)
What is the loss?
(c)
What is the loss's gradient with respect to the first activation?
Check
Two classifiers are tested on the same examples: the first is wrong and the second right on 25, and the reverse on 10.
(a)
What is McNemar's statistic?
Check
An anomaly detector has recall 0.9 and false-alarm rate 0.002 at prevalence 0.01; it thresholds a 2D Mahalanobis distance.
(a)
What percentage of its alarms are real?
(b)
What threshold gives a 0.1% false-alarm rate?
Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.
Practice
Keep practicing
16 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.