Use this workbook with the full assigned readings. Work independently, then compare each explained solution. Practice and projects are voluntary. Cases and datasets are fictional unless a primary passage is explicitly named.
A baseline must receive the same information
An experiment compares complete learning procedures, not isolated model names. The baseline and candidate must share the prediction timestamp, allowed features, target definition, evaluation cases and metric. A simple baseline can be strong when most variation is predictable from a stable group or season. A complex candidate can appear superior by using information unavailable when the decision must be made.
Separate fitting, model selection and final evaluation. Hyperparameters chosen after looking at test results make those results development evidence. Reproducibility includes the split rule and selection history, not just a seed.
Worked problem
Training targets are [10,20,30]. An unseen test contains [15,35]. Compare the training-mean baseline with predictions [18,30] using mean absolute error.
Trace the complete solution
The baseline is 20, calculated from training only. Test absolute errors are 5 and 15, so MAE=10.
Candidate errors are 3 and 5, so MAE=4. The observed improvement is 6 units on these two cases.
The candidate’s relative error reduction is 60%, but two cases do not establish stable population performance. Examine uncertainty and case selection.
Confirm the candidate used no final outcomes or post-decision features. Equal metrics do not repair unequal information.
Independent transfer problem
The candidate used final payment date to predict lateness at invoice creation. What changes in the conclusion even though its MAE is smaller?
Compare the reasoning and result
The feature is unavailable at the prediction timestamp, so the comparison does not establish deployable improvement. Remove that information, refit using development data, and evaluate the revised procedure. Report the corrected outcome rather than preserving the original improvement claim. The arithmetic remains correct for a retrospective task but answers the wrong decision.
A logistic model computes a score z, transforms it with a sigmoid and applies a chosen threshold for a decision. These are three distinct objects. A sigmoid maps numbers into (0,1), but that range alone does not establish calibration. A set of predictions near .8 is calibrated only if the relevant outcome occurs about 80% of the time in the defined setting, subject to sampling uncertainty.
Changing the threshold changes sensitivity and false alerts without changing the fitted probability model. Regularization constrains fitting; it does not select a universally correct operational threshold. Use numerically stable sigmoid evaluation and assess calibration on data independent of fitting.
Worked problem
Four predicted probabilities are [.2,.4,.7,.9] and outcomes are [0,1,1,0]. Compare confusion matrices at thresholds .5 and .8, defining positive as probability≥threshold.
Trace the complete solution
At .5, the last two are predicted positive: TP=1, FP=1, FN=1, TN=1.
At .8, only .9 is positive: TP=0, FP=1, FN=2, TN=1. Precision becomes 0/1=0 and recall 0/2=0.
This small example shows that a higher threshold does not guarantee an improved empirical precision on every finite dataset.
The .9 error does not alone prove global miscalibration. Assess calibration across enough cases and relevant subgroups rather than interpreting a single probability as certainty.
Independent transfer problem
A stakeholder demands that every .9 prediction be correct. Explain the probability misconception and propose an evaluation.
Compare the reasoning and result
A calibrated .9 forecast permits about 10% negatives in the corresponding population; it is not a deterministic guarantee. Evaluate reliability across probability bins with counts and uncertainty, inspect subgroup differences, and assess whether the deployment distribution matches evaluation. If errors have severe consequences, add review or abstention rather than promising certainty from a threshold.
A decision tree routes a case through threshold predicates. A path can explain how that fitted tree produced a result, but does not automatically explain the real-world cause of the outcome. A feature may be predictive because it records a downstream consequence or a proxy for another process. Feature importance also depends on the fitting method and correlated alternatives.
Audit threshold boundaries with values below, equal to and above the split. Establish whether a missing-value policy is supported by the actual implementation. A readable tree can still be overfit, leaked or unfairly evaluated.
Worked problem
A tree predicts late delivery if final collection_attempts>0. It achieves near-perfect retrospective accuracy. The decision is intended at shipment creation. Diagnose the result.
Trace the complete solution
Collection attempts occur after the billing or delivery process. They may encode the outcome or its consequences rather than an available shipment-time predictor.
List every feature’s availability time. Remove or reconstruct downstream fields at the prediction boundary before fitting.
Evaluate a revised tree on held-out cases with the same timestamp rules. The original high score does not transfer to the deployable task.
A path explanation saying collection_attempts caused the prediction describes model routing, not proof that collection calls caused late delivery.
Independent transfer problem
A split is hours>8. Evaluate 8, 8.01 and missing. Why is a missing policy necessary even when every development row had a value?
Compare the reasoning and result
Eight routes to the not-greater branch; 8.01 routes to the greater branch. Missingness is not determined by those comparisons alone and requires the implementation’s explicit policy or rejection. Deployment can introduce missing values not seen in development. Test the actual library’s behavior rather than assuming a universal tree rule.
A neural network composes functions. Backpropagation applies the chain rule to local derivatives and accumulates contributions along paths. For h=ReLU(wx+b) and output v·h, a negative preactivation makes the derivative through that ReLU path zero. It does not prove the entire network has zero gradient or that no other input can activate that unit.
Distinguish representation from learning. Supplying weights that realize a function demonstrates expressiveness; it does not establish that an optimizer will discover those weights from limited data. Training evidence requires a specified loss, data, initialization, updates and independent evaluation.
Worked problem
Let x=2,w=1,b=−1,v=3,y=0, output=v·ReLU(wx+b), and loss=.5(output−y)². Compute output and gradients with respect to v and w.
Trace the complete solution
Preactivation is 1, so h=1 and output=3. The loss is 4.5; dL/doutput=3.
doutput/dv=h=1, so dL/dv=3.
The active ReLU derivative is 1. doutput/dw=v×1×x=6, hence dL/dw=18. Similarly dL/db=9.
If w becomes 0 with the other parameters unchanged, preactivation is −1 and this path’s gradients with respect to w,b and v are zero for this example. The statement is local to this input and path.
Independent transfer problem
Two hidden units contribute to the output; one is inactive and the other active. Does the inactive unit prove the model cannot learn from this example?
Compare the reasoning and result
No. The active unit can transmit nonzero gradients, and any output bias can also update. Compute each path’s derivative and sum contributions for shared parameters. Avoid replacing a local zero derivative with a global training claim. Inspect gradient values and loss changes numerically on a small example.
Attention weights and unsupported factual conclusions
Attention forms a weighted combination of value representations using normalized scores. Softmax weights are positive and sum to one, but normalization is not a truth test. A high weight can reflect learned compatibility within the model rather than verified factual support. A generated sentence requires evidence beyond interpreting one internal weight.
Subtracting the maximum score before exponentiation preserves softmax ratios and helps numerical stability. This algebraic transformation changes neither the intended distribution nor the need to handle very large or invalid inputs carefully.
Worked problem
Scores are [0, ln(3)] and values are [10,30]. Calculate the attention-weighted scalar, then explain what it does not establish.
Trace the complete solution
Exponentials are [1,3]; normalized weights are [.25,.75].
The result is a representation calculation. It does not establish that the second passage is true or supports a generated factual claim. That requires inspecting evidence and entailment.
Independent transfer problem
A model places .95 attention weight on a sentence that quotes a false claim in order to refute it. Can that weight justify citing the claim as true?
Compare the reasoning and result
No. Attention strength does not encode the cited sentence’s argumentative role or prove entailment. Read the surrounding passage and distinguish quotation, negation and endorsement. An answer should cite the evidence for the conclusion it actually states, not treat a numerical attention weight as an authority score.
Evaluation describes a model under a particular data-generation and decision setting. Feature checks can reject values outside a contract, while distribution shift can occur entirely inside those ranges. Monitor data, predictions and outcomes where outcomes become available, and specify actions for suspected degradation. A model version change can alter behavior even when application code is unchanged.
A release decision should compare a baseline, candidate performance, operational costs and failure cases. Preserve a fallback, record versions and use a rollback trigger tied to observed behavior. Absence of an alarm is not proof that the system remains valid.
Worked problem
A model is 94% accurate on an old process and 51% on fictional cases from a changed rule. All input values still pass the schema. Evaluate release readiness.
Trace the complete solution
The schema confirms representation and range, not stability of the target relationship. Both measurements can be valid for different mechanisms.
Investigate whether deployment now follows the changed process. If so, the old score does not establish current usefulness.
Compare the candidate with simple baselines on the relevant new data and inspect errors, costs and subgroup patterns.
Delay or restrict automated use when the deployment evidence is insufficient. Use a defined fallback and collect feedback rather than silently averaging the two accuracies.
Independent transfer problem
A monitored model has unchanged feature averages but worse outcomes. What should the investigation include?
Compare the reasoning and result
Check conditional relationships, subgroup composition, label definition and delay, data-pipeline changes and decision thresholds. Equal marginal averages can hide changed relationships or offsetting subgroup shifts. Reproduce the evaluation with versioned inputs and targets, and do not dismiss outcome degradation because one feature summary is stable.
Run a reproducible fictional prediction experiment comparing a training-only baseline, a classical model and a small neural model. Define the prediction timestamp, feature availability and grouped/time-aware splits. Include threshold and calibration analysis, a manual gradient check, a changed-mechanism test, and a release decision with fallback criteria.
Evidence and evaluation criteria
Equal information and evaluation cases for every candidate and baseline.
Training/development/test separation with a recorded model-selection process.
Independent metric calculations and confusion matrices at two thresholds.
A chain-rule derivation checked against numerical behavior away from nondifferentiable points.
A changed-mechanism experiment with case-level error analysis and subgroup limits.
A versioned decision memo stating costs, uncertainty, fallback and rollback conditions.
Worked project approach and limitations
First fit the training-mean baseline and independently compute held-out MAE. Remove all features unavailable at the declared decision time before comparing models. For the two-layer numerical example, obtain output 3, dL/dv=3 and dL/dw=18; compare a small numerical perturbation away from the ReLU kink. Evaluate probability calibration with counts rather than declaring every .9 error a defect. Run the supplied neural experiment on both original and changed synthetic mechanisms, preserving the disappointing result. A useful report explains when the baseline wins and when evidence does not support release. Synthetic success establishes behavior in the constructed experiment, not general effectiveness on real business populations.
Cumulative assessment
These are new situations. Explain your choice before opening the feedback.
Problem 1
Training targets [4,8,12] give a constant-mean baseline. Against test [6,14], what is MAE?
4
0
10
Answer and reasoning for every option
Best answer: A
Correct. The baseline is 8; errors 2 and 6 average 4.
Incorrect. The test values are not both the training mean.
Incorrect. That is the test mean, not baseline MAE.
Problem 2
A model uses a post-outcome field for a prediction made earlier. What is required?
Only rename the feature
Keep the score because the test was large
Reconstruct features at the prediction timestamp and reevaluate
Answer and reasoning for every option
Best answer: C
Incorrect. A name change does not remove information.
Incorrect. Large leaked evaluations still answer the wrong task.
Correct. The current experiment gives the candidate unavailable information.
Problem 3
A calibrated .8 forecast is wrong on one case. What follows?
The outcome record must be deleted
One error is compatible with probabilistic calibration
Calibration is necessarily disproved
Answer and reasoning for every option
Best answer: B
Incorrect. That biases evaluation.
Correct. Calibration concerns outcome frequencies over appropriate cases.
Incorrect. An .8 forecast allows negative outcomes.
Problem 4
A tree path identifies a feature used by the model. What does it not establish by itself?
That intervening on the feature causes the outcome
Which branch was used
That a prediction was produced
Answer and reasoning for every option
Best answer: A
Correct. Model routing differs from causal identification.
Incorrect. The path can identify routing.
Incorrect. The observed path may indeed produce one.
Problem 5
For h=ReLU(wx), x=2,w=−1, what is dh/dw away from the kink?
2
−2
0
Answer and reasoning for every option
Best answer: C
Incorrect. That would apply on the active branch.
Incorrect. The negative input product does not give a negative ReLU slope.
Correct. The preactivation is negative, so this ReLU path is locally flat.
Problem 6
One neural path has zero gradient. What should be examined before declaring learning impossible?
Nothing; one zero proves every parameter is fixed
Other active paths and trainable parameters
Only the model’s name
Answer and reasoning for every option
Best answer: B
Incorrect. The conclusion exceeds the local derivative.
Correct. A local zero does not prove a global zero.
Incorrect. Names do not determine the gradient.
Problem 7
Softmax scores [0,0] weight scalar values [4,10]. What is the context?