CS230 — Original on-site preparation

Independent written study. All essential explanations and optional model reasoning for this chapter are on this page. References are optional further study. No degree, professional approval or observed competence is conferred.

Aster: one reproducible mathematical decision record

This fictional application connects the existing course investigations. Aster plans a flagging system for incoming service jobs. Its target is whether a job will require a repeat visit within seven days. The decision occurs when the initial request is accepted. Each row represents a job; customers may have several jobs. The proposed use concerns new customers next quarter. All data and costs below are constructed. Practice and submission are optional.

The feature contract uses [estimated hours, number of visits already requested], with coefficients [1000 cents/hour,500 cents/visit] and a 200-cent intercept. Two records are [2,3] and [4,1]. A data export proposes converting hours to minutes while retaining coefficients. Another proposed feature, final_resolution, is created after the repeat-visit outcome. Training values for a separate numeric feature are [2,missing,6]; held-out values are [100,missing]. A colleague proposes a fill mean computed from both partitions.

For an independent mathematics check, use the fictional observations (x,y)=(0,1),(1,3),(2,5). Fit b+wx by minimizing mean squared error, derive both normal equations, and calculate one simultaneous gradient step from b=w=0 with rate .1. This tiny regression fixture is a calculation exercise; it is not the deployed classification model or evidence about repeat visits.

A development sample gives policy A counts TP=30,FP=10,FN=20,TN=140 and policy B counts TP=40,FP=40,FN=10,TN=110. Each missed positive costs 100 fictional cost units and each false alert costs five. The team can review 50 alerts in a batch. A final untouched evaluation set has not yet been used. A separate hypothetical reference population has 1% positive prevalence, sensitivity .9 and false-positive rate .05. Explain why neither development confusion matrix can automatically supply precision for that other population.

Produce a dossier with the feature/shape contract, preprocessing and partition plan, regression derivation, natural-frequency table, policy metrics and costs, capacity decision and evaluation limitations. Then change the record: a feasible policy C produces TP=35,FP=15,FN=15,TN=135 on the same 200 development cases. It meets the 50-alert capacity. Determine whether its error cost establishes a final deployment decision.

Complete worked dossier and changed-record reasoning

Representation. The two-row feature matrix is 2×2, the coefficient vector is 2×1 and predictions are 2×1. Dot products plus intercept give 3700 and 4700 cents. Converting hours to minutes requires 1000/60 cents/minute; retaining 1000 multiplies only that feature's contribution by 60. A matching array shape would not reveal the unit error. Keep the observation unit and ordered feature names alongside parameters.

Availability and fitting. Remove final_resolution from an acceptance-time predictor because it is created after the target. Fit imputation only on training values: (2+6)/2=4, giving training [2,4,6] and held-out [100,4]. Whole-data fitting gives 36 and leaks the held-out feature distribution. This is not a recommendation that mean imputation is always appropriate. Record missingness mechanisms, all-missing-column policy, scaling and unknown-category behavior. Each cross-validation fold must fit its own transformers on its training subset.

Partition. A new-customer, future-quarter claim needs both entity separation and a credible time boundary. A purely random row split can place the same customer on both sides; a customer-only split can still use later observations to predict earlier ones. Define customer assignment and cutoff, exclude post-cutoff predictors, account for labels whose seven-day windows are incomplete, and keep all development/model selection separate from the final evaluation. A combined group/time design can reduce sample size and leave shift risks; document these instead of choosing the split with the best score.

Derivation. Let rᵢ=b+wxᵢ−yᵢ and L=Σrᵢ²/3. Differentiation gives ∂L/∂b=2Σrᵢ/3 and ∂L/∂w=2Σrᵢxᵢ/3. At a stationary point, 3b+3w=9 and 3b+5w=13, because Σx=3,Σy=9,Σx²=5,Σxy=13. Subtracting yields w=2 and b=1. The intercept column and x column are independent here; identical x values would not identify a unique pair.

At the zero start, residuals are [−1,−3,−5], L=35/3, and gradient is [−6,−26/3]. The simultaneous rate-.1 update gives b=3/5,w=13/15. New residuals are [−2/5,−23/15,−8/3]. The new mean loss is 433/135≈3.207407, below 35/3. This verifies one step on this fixture, not convergence for every rate or generalization. Numerical implementations should compare tolerances and loss conventions, not require equality for arbitrary floating-point calculations.

Reference population. In 10,000 hypothetical jobs with 1% prevalence, there are 100 positives and 9900 negatives. The specified conditional rates give 90 true alerts and 495 false alerts, so precision is 90/585≈.153846. Sensitivity uses actual positives as its denominator; precision uses all alerts. The development fixtures have 50 positives among 200 cases, a different prevalence. Even transporting conditional rates needs evidence of their stability; a denominator calculation is not a validation of that transport.

Policies. A has accuracy170/200=.85, precision30/40=.75, recall30/50=.6 and error cost20×100+10×5=2050. It generates40 alerts and fits capacity. B has accuracy150/200=.75, precision40/80=.5, recall40/50=.8 and error cost10×100+40×5=1200. Its80-alert workload exceeds50. Choosing B solely by its unconstrained cost ignores feasibility. Reviewing only its top50 is a new policy whose counts must be measured; its recall cannot be inherited from all80 alerts.

Changed policy C. C has accuracy170/200=.85, precision35/50=.7, recall35/50=.7 and error cost15×100+15×5=1575. It is feasible on this batch and improves the stated development error cost by475 relative to A. This supports selecting C as a development candidate under these constructed criteria. It is not final deployment evidence: choices were made using these cases. Freeze the candidate, threshold, preprocessing and review policy before the untouched evaluation. Include review labor for true alerts, intervention effects, subgroup denominators, uncertainty, privacy/authorization and monitoring where relevant; the stated error cost does not equal total business profit.

Conclusion. Preserve the original data contract, reject post-outcome features, fit transformations inside training boundaries and evaluate a feasible policy matching future new-customer use. Reproduce the calculations with an independent implementation and keep expected and observed results in the report. Distinguish exact mathematical identities, sampling assumptions and unverified empirical claims.

Optional 20-point rubric. Award0–4 points for each criterion: (1) dimensions, ordered units and conversion; (2) derivative/normal-equation/step derivations with independently verified numbers; (3) conditioning table and correct metric denominators; (4) customer/time/availability/preprocessing boundaries and their limitations; (5) feasible policy comparison, changed C analysis and honest final-evaluation scope. For each criterion,4 means complete correct reasoning with stated assumptions,3 a correct conclusion with one limited omission,2 partial reasoning with a material gap,1 an unsupported assertion and0 absent or contradictory work. Compare reasoning rather than just totals; no learner score or completion is recorded by this guide.

Optional source references

These sources support the explanations; reading them is optional. Original Academy examples are fictional. Historical attributed readings remain preserved.