Milestone 5 of 8
Select and verify the winning candidate
Apply the exact row-major tie rule, reconstruct predictions and signed differences, and prove no stored score is smaller.
Selection is a rule applied to saved scores. Keep the tie rule and the reconstruction visible instead of treating a convenient array position as an answer.
Goal
Select the smallest score under the exact tie rule, reconstruct its prediction and signed differences, hand-check one point, and verify that no stored score is smaller.
Inputs
Use the complete score grid and ordered candidate arrays from the previous milestone. The tie rule is exact: when scores are equal, retain the first pair in row-major candidate order. The signed difference is:
observed - predicted
Use the generated input and observed arrays to reconstruct the selected prediction values.
Deliverables
Implement selection in src/search.py or a clearly separated result function.
Return the selected slope, intercept, grid indexes, score, predictions, signed
differences, and candidate-grid identity.
Save output/selected_result.json with the selected values and arrays, or use
an equally explicit JSON record. Include a minimality statement that points to
the stored score grid.
Checks
Use a public fixture with a unique minimum and another with an exact tie. Check that the unique minimum is selected, the first tied pair is retained, and the selected indexes map to the recorded slope and intercept. Recompute predictions and signed differences from the selected candidate and compare each value.
Check one point by hand, confirm the selected score equals the mean squared difference of its reconstructed predictions, and prove that no stored score is smaller. Check that the score grid, candidate arrays, and generated data are not mutated.
Workspace
Keep the selection and reconstruction boundary in src/search.py. Write the
selected record under output/ and leave the full score evidence unchanged.
src/report.py will later read this result rather than recomputing a winner
from an unstated rule.
Hints
HintIndexes carry the tie order
HintReconstruct before describing
Review
Read the selected result next to the score grid. Explain why “best” here means smallest score among the supplied candidates and why the tie rule matters.
How to check your work
Checks compare selection, tie handling, and minimality evidence with the supplied fixture. The supplied fixture does not support a claim about a continuous or universally optimal line.