Module 12 · Responsible systems
Module 12: construction feedback
Try practice before reading the worked notebook. Download solutions or open notebooks/practice/module12-solutions.ipynb in the complete source tree. If a download link does not open, use the offline access route.
valid_request
Booleans are not numerical measurements in this contract; reject extras. For valid_request({'x': 2}, ['x']), the expected result is True.
def valid_request(record, expected):
import math
return set(record)==set(expected) and all(type(record[k]) in [int,float] and math.isfinite(record[k]) for k in expected)
shift_score
Use the fixed training scale, not a scale fitted on new requests. For shift_score(12, 10, 2), the expected result is 1.
def shift_score(current_mean, training_mean, training_scale):
return abs(current_mean-training_mean)/training_scale if training_scale>0 else None
nearest_rank
Name the percentile convention and retain the tail request. For nearest_rank([1, 2, 3, 100], 0.95), the expected result is 100.
def nearest_rank(values, percentile):
import math
return sorted(values)[math.ceil(percentile*len(values))-1]
Complete-study results feedback
In the verified CI run 40697234797 (October 28, 2026), the four batches had 95th percentiles of 1.37, 1.10, 1.09 and 1.12 ms against means of 1.20, 1.06, 1.06 and 1.06 ms. With about 61 requests per batch, the 95th percentile is the 58th or 59th value, so it reflects the slower tail that a mean smooths away. Local CPU timings are not production latency.
Reasoning task feedback
The 95th percentile is the value at position ceil(0.95 × 4) = 4, which is 0.250 s, while the mean is about 0.071 s and hides the slow request. Below 20 requests, ceil(0.95 × n) equals n, so the 95th percentile is the maximum. With 20 requests it is the second largest. Report the sample count with any percentile.
Advanced extension feedback: JSON API
A complete record returns 200 with the probability, the decision at the frozen 0.3 threshold and any features outside the training range. The extra quality field returns 422 with "Supply exactly the eleven chemistry features; no quality/label/extra fields."; "alcohol": true returns 422 with "alcohol must be numeric."; and invalid JSON returns 400. Rejecting with a reason makes errors visible to the caller; silently dropping a field or treating true as 1 would hide a broken client and could feed the model meaningless inputs.
A local server demonstrates the contract, not a deployment. Exposing it would need authentication, rate limits, a logging policy that avoids storing inputs unnecessarily, the monitoring from this module, and a named owner with a rollback plan.
Judge the explanation
Compare your explanation with the criteria in the study workflow: passing the visible checks alone is developing; a changed case that you predict, implement and explain meets the task.
Transfer feedback
Write a service response policy for an invalid request, a model outage and an alert without outcome labels. A defensible response rejects the invalid request with a reason, routes outages to the human fallback, and treats an input-shift alert as an investigation until delayed labels arrive. It names the owner and the rollback trigger.