AI 301 — Machine Learning, Neural Networks and Language — Reasoning and Practice

Full teaching sequence and cumulative subject work

Train a logistic model and expose a changed mechanism — primary material, constructed-response tasks, complete worked model and changed-case examination →

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
  1. The baseline is 20, calculated from training only. Test absolute errors are 5 and 15, so MAE=10.

  2. Candidate errors are 3 and 5, so MAE=4. The observed improvement is 6 units on these two cases.

  3. The candidate’s relative error reduction is 60%, but two cases do not establish stable population performance. Examine uncertainty and case selection.

  4. 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.

Open the unit and assigned readings →

Scores, thresholds and calibrated probabilities

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
  1. At .5, the last two are predicted positive: TP=1, FP=1, FN=1, TN=1.

  2. At .8, only .9 is positive: TP=0, FP=1, FN=2, TN=1. Precision becomes 0/1=0 and recall 0/2=0.

  3. This small example shows that a higher threshold does not guarantee an improved empirical precision on every finite dataset.

  4. 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.

Open the unit and assigned readings →

Trees, leakage and explanations of a decision

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
  1. Collection attempts occur after the billing or delivery process. They may encode the outcome or its consequences rather than an available shipment-time predictor.

  2. List every feature’s availability time. Remove or reconstruct downstream fields at the prediction boundary before fitting.

  3. Evaluate a revised tree on held-out cases with the same timestamp rules. The original high score does not transfer to the deployable task.

  4. 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.

Open the unit and assigned readings →

Backpropagation as a local chain 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
  1. Preactivation is 1, so h=1 and output=3. The loss is 4.5; dL/doutput=3.

  2. doutput/dv=h=1, so dL/dv=3.

  3. The active ReLU derivative is 1. doutput/dw=v×1×x=6, hence dL/dw=18. Similarly dL/db=9.

  4. 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.

Open the unit and assigned readings →

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
  1. Exponentials are [1,3]; normalized weights are [.25,.75].

  2. The weighted value is .25×10+.75×30=25.

  3. Subtracting ln(3) gives exponentials [1/3,1], whose normalized weights remain [.25,.75].

  4. 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.

Open the unit and assigned readings →

Deployment shift and a bounded release decision

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
  1. The schema confirms representation and range, not stability of the target relationship. Both measurements can be valid for different mechanisms.

  2. Investigate whether deployment now follows the changed process. If so, the old score does not establish current usefulness.

  3. Compare the candidate with simple baselines on the relevant new data and inspect errors, costs and subgroup patterns.

  4. 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.

Open the unit and assigned readings →

Integrated project

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

  1. Equal information and evaluation cases for every candidate and baseline.
  2. Training/development/test separation with a recorded model-selection process.
  3. Independent metric calculations and confusion matrices at two thresholds.
  4. A chain-rule derivation checked against numerical behavior away from nondifferentiable points.
  5. A changed-mechanism experiment with case-level error analysis and subgroup limits.
  6. 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?

  1. 4
  2. 0
  3. 10
Answer and reasoning for every option

Best answer: A

  1. Correct. The baseline is 8; errors 2 and 6 average 4.
  2. Incorrect. The test values are not both the training mean.
  3. 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?

  1. Only rename the feature
  2. Keep the score because the test was large
  3. Reconstruct features at the prediction timestamp and reevaluate
Answer and reasoning for every option

Best answer: C

  1. Incorrect. A name change does not remove information.
  2. Incorrect. Large leaked evaluations still answer the wrong task.
  3. Correct. The current experiment gives the candidate unavailable information.

Problem 3

A calibrated .8 forecast is wrong on one case. What follows?

  1. The outcome record must be deleted
  2. One error is compatible with probabilistic calibration
  3. Calibration is necessarily disproved
Answer and reasoning for every option

Best answer: B

  1. Incorrect. That biases evaluation.
  2. Correct. Calibration concerns outcome frequencies over appropriate cases.
  3. 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?

  1. That intervening on the feature causes the outcome
  2. Which branch was used
  3. That a prediction was produced
Answer and reasoning for every option

Best answer: A

  1. Correct. Model routing differs from causal identification.
  2. Incorrect. The path can identify routing.
  3. 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?

  1. 2
  2. −2
  3. 0
Answer and reasoning for every option

Best answer: C

  1. Incorrect. That would apply on the active branch.
  2. Incorrect. The negative input product does not give a negative ReLU slope.
  3. 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?

  1. Nothing; one zero proves every parameter is fixed
  2. Other active paths and trainable parameters
  3. Only the model’s name
Answer and reasoning for every option

Best answer: B

  1. Incorrect. The conclusion exceeds the local derivative.
  2. Correct. A local zero does not prove a global zero.
  3. Incorrect. Names do not determine the gradient.

Problem 7

Softmax scores [0,0] weight scalar values [4,10]. What is the context?

  1. 7
  2. 14
  3. 10
Answer and reasoning for every option

Best answer: A

  1. Correct. Equal scores yield weights one-half each.
  2. Incorrect. That sums values without normalization.
  3. Incorrect. Equal scores do not select only the second value.

Problem 8

High attention weight falls on a quoted claim that the passage rejects. What should a factual answer do?

  1. Assert the quotation as true
  2. Assume all attention calculations are numerically invalid
  3. Inspect the passage’s argumentative role and actual support
Answer and reasoning for every option

Best answer: C

  1. Incorrect. That ignores its rejection.
  2. Incorrect. The arithmetic can be valid while the factual inference is wrong.
  3. Correct. Attention weight is not an entailment guarantee.

Problem 9

A model’s input ranges are unchanged but predictive relationships shift. What can happen?

  1. Only display formatting changes
  2. Performance can degrade despite passing schema checks
  3. The schema guarantees the old accuracy
Answer and reasoning for every option

Best answer: B

  1. Incorrect. The predictive relationship can materially change.
  2. Correct. Schema validity is not distributional validity.
  3. Incorrect. It constrains representation, not the target mechanism.

Problem 10

A higher threshold produces worse observed precision on a small test. What is warranted?

  1. Inspect the actual counts; improvement is not guaranteed on every sample
  2. Overwrite the counts to match intuition
  3. Thresholds never affect outcomes
Answer and reasoning for every option

Best answer: A

  1. Correct. Finite datasets can rank threshold behavior unexpectedly.
  2. Incorrect. That fabricates evidence.
  3. Incorrect. They change predicted positives.

Problem 11

Two model versions use the same application code. What must be included in reproducibility records?

  1. Only the repository filename
  2. Only the release date
  3. The model and preprocessing versions as well as application code
Answer and reasoning for every option

Best answer: C

  1. Incorrect. It does not identify the actual model configuration.
  2. Incorrect. Several configurations can share a date.
  3. Correct. Behavior depends on the complete procedure.

Problem 12

A candidate wins on one selected subgroup but loses overall. What should the report do?

  1. Hide all subgroup results
  2. Report the prespecified objective and disaggregated results transparently
  3. Present the subgroup score as universal accuracy
Answer and reasoning for every option

Best answer: B

  1. Incorrect. They can reveal important failures and should be contextualized.
  2. Correct. A selected favorable slice cannot stand for all deployment cases.
  3. Incorrect. That changes the population claim.

Assigned sources