Repository navigation
Solve parts (b) and (c) of the Wage polynomial exercise; scale age in the Python CV - #1399
Conversation
… in the Python CV The exercise asks for a confidence band (b) and a cross-validated step function (c), but the solution only did (a). The Python solution also fed raw age**10 to least squares, which is ill-conditioned; it now standardizes age first, as the R solution's poly() does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nh61VJUp2V6tGvtkZ3BZKF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nh61VJUp2V6tGvtkZ3BZKF
|
Generated by Claude Code |
|
The re-run of Generated by Claude Code |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nh61VJUp2V6tGvtkZ3BZKF
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Main's term-link check now knows "interval" from the mcs prerequisite site, so link its first use in the exr-wage-polynomial-cv solution. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGiaktxMs3jUmMZBCv
This comment has been minimized.
This comment has been minimized.
check-one-div-per-subfile (now on main) fails a touched subfile that holds more than one top-level div. Move exr-wage-polynomial-cv and exr-backfitting, each with its solution, into their own subfiles, unchanged, and include them from _exr-gams-applied.qmd under the same headings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGiaktxMs3jUmMZBCv
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The review of 9764263 flagged exr-wage-polynomial-cv as one exercise with three asks. Give each ask its own exercise, solution and subfile: exr-wage-polynomial-cv (CV degree; keeps the old id), exr-wage-poly-band (fit with a 95% band) and exr-wage-step-cv (CV cut-points). Each later exercise names the data and cites the earlier one it builds on. Also link the terms these reworded lines use, fix the polynomial link (the mds definition moved to algebra-polynomials.html), and explain the equal-width bins next to the Python code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGiaktxMs3jUmMZBCv
|
Claude finished review — View run I reviewed head Earlier findings
What changed in
|
Built to branch |
Before:
exr-wage-polynomial-cvasks for a confidence band (b) and a cross-validated step function (c), but its solution only did (a). The Python solution passed rawage**10to least squares, which is ill-conditioned, and its folds were not shuffled.After: the R and Python solutions both do (a), (b) and (c). Python standardizes
agebefore taking powers, as the R solution'spoly()does, and uses shuffled folds. R and Python pick the same answers: degree 9 and 7 cut-points.How: only
_subfiles/generalized-additive-models/_exr-gams-applied.qmdchanges. I renderedchapters/generalized-additive-models.qmdto HTML with no warnings; the R output reads "CV-selected degree: 9" and "CV-selected number of cut-points: 7". The Python chunk is not run in the rme render (eval: false), so I ran it locally against the sameWagedata and got the same two values.typosis clean on the file. Part of the drift audit in Morrison-Lab/lds#1214, which listed these as follow-ups to rme#1393.Differences from the source (ISLRv2 Applied 6):
PolynomialFeatureson raw ageKcut-points makeK + 1intervals, stated in the textUpdate (2026-12-02), after merging
main(185 commits behind):main's term-link check knows the term.check-one-div-per-subfile, now onmain, fails a touched subfile with more than one top-level div.So
exr-wage-polynomial-cvandexr-backfittingeach move, with their solutions and unchanged, into their own subfiles:_exr-wage-polynomial-cv.qmdand_exr-backfitting.qmd._exr-gams-applied.qmdkeeps the source notes and the two headings and includes the new files.So it is now three exercises, each with its own solution and subfile:
exr-wage-polynomial-cv(choose the degree by CV; keeps the old id), in_exr-wage-polynomial-cv.qmd;exr-wage-poly-band(fit the chosen degree with a 95% band), in_exr-wage-poly-band.qmd;exr-wage-step-cv(choose the cut-points by CV), in_exr-wage-step-cv.qmd.Each later exercise names the
Wagedata and cites the exercise it builds on.The code is unchanged, only split between the three solutions.
main's term-link check requires.mds/algebra-exponentials.html#def-polynomial, which no longer has that anchor; it now points atalgebra-polynomials.html.cut()and the ISLR lab (§7.8.1), and quantile bins are the alternative.Generated by Claude Code
Generated by Claude Code