Use the question’s probability event, units, and noise assumptions before substituting numbers. In , the second parameter is variance. A hat marks an estimate or prediction.
Bayes rule
Use for Problems 1, 3, 4. To minimize expected mistakes with equal error costs, choose the most probable class at each input.
Let be the conditional probability of class at predictor value . For multiple classes, : the label with largest probability. For two classes,
Either class is optimal at a tie; this module uses 1. If given instead, predict 1 when . Respect any stated domain. Check: gives prediction 1 and conditional error .
With false-positive cost and false-negative cost , assuming correct decisions cost zero, predict 1 when
Why: the expected cost of predicting 1 is ; predicting 0 costs . Choose the smaller. Invented check: costs 1 and 4 give a threshold .
Classification errors
Use for Problems 3, 4. Positive means actual or predicted class 1. counts correct positives; counts positives predicted 0; counts negatives predicted 1; counts correct negatives.
| Actual class | Predict 1 | Predict 0 |
|---|---|---|
| 1 | TP | FN |
| 0 | FP | TN |
Rates require a nonzero actual-class denominator. Sheet check: gives and .
For a sigmoid probability, is increasing and . Thus the decision boundary is . The favored class is the event inside the supplied probability. In Problem 3, , so predicts 0, and the boundary is .
Flipping all predictions swaps the two columns of the table; it does not change actual class totals.
Expectation and dependence
Use for Problem 4. If with independent of , , and , then
Here is the supplied deterministic rule, is the best squared-error prediction, and the last quantity is irreducible MSE. Sheet check: and noise give and irreducible MSE 2. A marginal noise distribution alone does not imply independence.
For random variables with finite, nonzero variances, let be their standard deviations. Then
Independence implies zero covariance. Zero covariance does not imply independence. Counterexample: uniform on and are dependent, but , so their covariance and correlation are zero. Correlation alone also does not establish causation.
Model flexibility
Use for Problems 4, 6. To measure new-data error, use predictions on observations that were not used for fitting. For evaluation pairs and fitted rule ,
Select flexibility using validation MSE or cross-validation; reserve a final test set for evaluation after selection. Invented check: validation MSEs 4, 2, 3 for increasing flexibility favor the middle model.
At fixed input , for a new independent response and fitted model trained on random dataset ,
Here , , and is irreducible noise. The expectation averages over training datasets and fresh response noise. Overfitting by a very flexible model is associated with high variance, not high bias.
When an enlarged model contains the old model and both minimize ordinary training RSS on the same data,
It can match the old model by setting new coefficients to zero. Equality is possible. There is no corresponding general guarantee for test RSS or for an arbitrary subgroup’s RSS; Problem 6’s unchanged male fit follows from that model’s separate group parameters.
Coin flips
Use for Problem 5. Assume independent flips, each with heads probability . With heads and tails,
The binomial coefficient counts choices of head positions. Factorial , with .
Sheet check: ; 20 heads in 30 flips has probability . Use the counting factor only when different orders qualify.
ROC and AUC
Use for Problem 8. Let be the true label and the prediction. An ROC curve plots
as a threshold or classifier parameter varies. AUC is the area under this curve in the unit square.
If an independent coin predicts 1 with probability , both conditional probabilities are :
Varying from 0 to 1 traces the diagonal, whose triangular area is . Check: gives and FNR . A fixed is one point; the family gives the curve. With no label-related information, population AUC cannot systematically rise above or fall below ; sample estimates can fluctuate by chance.
Least squares · Fit an intercept and slope
Use this for a straight-line prediction . The intercept is the fitted response at ; the slope is the change in the fitted response for a one-unit increase in .
For supplied points , calculate the means:
Measure horizontal spread and joint variation:
When , the coefficients minimizing squared residuals are:
Use it. Problem 2 gives , , , and . Thus and .
The fitted line estimates the mean response. If the model’s noise has known nonzero mean , the fitted intercept estimates ; see shifted noise.
Fit quality · RSS, RSE, and R²
For observation , the residual is , where is observed and is fitted. With observations:
RSS is total squared prediction error on the observations being evaluated. For a simple linear model with a fitted intercept and slope, the residual standard error is:
The denominator uses residual degrees of freedom because two coefficients were estimated. RSE has the same units as the response.
Let be the observed response mean. The total sum of squares is the error from always predicting that mean:
For , the fraction of baseline squared error removed by the fit is:
Use it. Problem 2 has , , and . Thus and .
Coefficient uncertainty · Known Gaussian noise variance
Assume , with fixed observed and independent errors . Here is the supplied noise standard deviation, is the observation count, is the predictor mean, and .
The standard errors describe how much the fitted coefficients vary over repeated samples:
For either coefficient ( for intercept, for slope), a 95% confidence interval is:
The normal multiplier 1.96 is rounded. Over repeated samples, this interval-building procedure covers the true fixed coefficient about 95% of the time.
Use it. Problem 2 supplies variance , so . With , the slope standard error is . Its estimate is 1.6, so its interval is .
If noise variance is instead unknown and estimated from residuals, an exact small-sample interval uses the appropriate multiplier and estimated standard errors. Problems 2 and 7 request intervals as functions of the supplied noise parameters, so use their given variances here.
Hypothesis tests · Compare a proposed coefficient with its interval
For a two-sided 5% test of , is the proposed coefficient, is its estimate, and is its standard error. Under independent Gaussian errors with known variance, use:
Reject when . Equivalently, reject when the proposed value lies outside the 95% interval:
Fail to reject when the inequality is reversed or equal. This means there is insufficient evidence against the proposed value at this level; it does not prove the null hypothesis.
Use it. In Problem 7, the slope estimate is 2, the proposed slope is 0, and its standard error is . Reject when , or .
Interactions · Substitute the group indicator
Let be a numeric predictor and a group indicator. In the fitted model:
the are fitted coefficients. Substitute the group value to read its line:
The prediction difference is . If , the lines meet at .
Use it. Problem 6 gives , , , and . The lines are and ; their crossing is .
Adding a term such as leaves the group linear and permits curvature for . When both fits minimize ordinary unpenalized RSS on the same training data, the extended model includes the old model at , so:
These fully interacted models allow independent group fits. With unconstrained coefficients, adding curvature only for leaves the minimum training RSS unchanged. If the line is identifiable (at least two distinct training values), its predictions and its RSS on the same test points also stay unchanged. Total test RSS has no guaranteed ordering.
Shifted noise · A nonzero mean changes the intercept
Suppose the model is , with noise independent of and . Here is its known mean and its variance. Then:
An ordinary fitted intercept estimates the mean-response intercept . Recover the original model’s intercept by subtracting the known noise mean:
If the interval for is , the interval for is . Its width is unchanged because is a known constant. The slope estimate and its uncertainty are unchanged for the same observations.
Use it. Problem 7’s printed data give . When the known noise mean is , the original intercept estimate is . Its 95% interval is , where is the supplied noise standard deviation.
If is unknown, these observations identify the sum , not its two components separately.