Skip to content

Define "prediction function" separately from "prediction" - #291

Merged
d-morrison merged 12 commits into
mainfrom
claude/prediction-function
Oct 31, 2026
Merged

d-morrison merged 12 commits into
mainfrom
claude/prediction-function

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Ezra (2026-10-29): should "prediction function" be defined separately from "prediction", and linked, for example from def-prediction-error?

def-prediction defines a prediction as a constant or g(X), a guess for the outcome.
The pages call the function g a "prediction function" and link that phrase to def-prediction, so the two concepts share one definition.

This adds def-prediction-function (a function from an input value to a prediction) and a short example, placed after def-input so it uses no term before it is defined.
It relinks the "prediction function" mentions that come after it: def-prediction-error, def-squared-error-risk, thm-best-predictor, lem-cross-term-zero, thm-risk-decomposition, def-reducible-risk and cor-best-predictor-argmin.

Not done, to stay at 10 files: the same relink in rem-reducible-risk and rem-irreducible-risk, and the mentions before def-input, which would be forward references.
Neither sds nor lds defines a prediction function (sds has def-prediction-rule, a fitted model used to predict), so nothing is duplicated.
Not rendered locally: expectation.qmd stops on a missing R package in an unrelated chunk, and the added text has no code.



Generated by Claude Code

A prediction is a guess (a constant, or g(X)); a prediction function is the
function g that produces it. The pages already say "prediction function" and
link it to the prediction definition. Add a prediction-function definition and
example after the input definition, and link the uses that follow it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

No source uses "excess risk" as a term for this quantity.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

check-one-div-per-subfile fails a PR that adds a line to a subfile holding
more than one div. Move the four examples to their own subfiles and include
them after the definition or result they follow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread _subfiles/_def-prediction-error.qmd Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…otes remark

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9nVFCSNv3sBfesyDpL
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dem-extra1

Copy link
Copy Markdown
Contributor

🤖 Antigravity agent report

Cross-harness review (Gemini 3.8 Flash (Medium) via Antigravity agy 1.3.5, standing in while Argon quota is exhausted, read-only plan mode) at 9ea7351

I gave the model the full diff (15 files, 13.6 KB) and facts I checked: the macros used (\predvar, \predfn, \predfnf, \truemeanf, \prederrf, \popriskf, \est) exist in the pinned macros commit; the bibliography key james2021islr2e exists in references.bib and is used elsewhere; and the moved examples keep their ids and are included after their results in expectation.qmd.
I checked the findings below against the files; nothing was rendered, and the build job was still pending when I looked.

The new definition and the redefined reducible risk are correct: E[(f(X) - mu(X))^2] is the quantity the old text called the reducible risk (with the squared difference written the other way round), and it matches the decomposition theorem.

Findings

  1. The relinked statements call f(X) the prediction function, which the new definition does not.
    def-prediction-function says a prediction function f is a function that takes a value of the input and returns a prediction f(x).
    The statements this PR relinks still read "For any prediction function $\predfnf{\Predvar}$ with $\E{\predfnf{\Predvar}^2} &lt; \infty$" (in thm-best-predictor, thm-risk-decomposition, lem-cross-term-zero, cor-best-predictor-argmin and def-squared-error-risk, def-prediction-error), so the link now points at a definition of a function while the text names the random variable f(X).
    Write "prediction function $\predfn$" in those places (and "$\predfnf{\Predvar}$ is square integrable" where the moment condition is meant), or define the term for both uses.
  2. The first mention in thm-best-predictor is unlinked (a nit).
    "Write $\bestpredfn \eqdef \truemean$ for the prediction function that uses it." comes before the linked "for any prediction function", so the link belongs on the first mention; check-term-links passes because the line is not added by this PR.
  3. The citation sentence needs a page check.
    @james2021islr2e [Section 2.1.1, p. 18] calls the squared difference between a [prediction function](#def-prediction-function) and the [conditional mean](#def-cond-expectation-function) the "reducible error".
    In that book the reducible error is the squared difference [f(X) - f_hat(X)]^2 between the estimate and the true regression function at X, so the claim is right in substance; I could not check the section and page number against the book, and "the squared difference between a prediction function and the conditional mean" mixes a function with a value (see item 1).

I disagree with the model's other two points: it says X is not introduced in the reducible-risk definition, but X is the notation for the input used throughout these notes, and the neighbouring definitions (def-squared-error-risk, def-prediction-error) use $\predfnf{\Predvar}$ in the same way; and it asks for "of the outcome associated with input $\predvar$" in the definition of a prediction function, which the phrase "returns a prediction of the outcome" already carries.

Verdict

VERDICT: FINDINGS

Reviewed-Commit: 9ea7351

Posted by Claude Code (AI agent) --- not written by a human.

…ments; link its first use in thm-best-predictor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWgYrE7LQ7q9Lw5qkHaNiT
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dem-extra1

Copy link
Copy Markdown
Contributor

🤖 Antigravity agent report

Cross-harness review (delta-focused, Gemini 3.8 Flash (Medium) via Antigravity agy 1.3.5, standing in while Argon quota is exhausted, read-only plan mode) at 8165b50

This supersedes my read of 9ea7351 and covers the compare 9ea7351...8165b50 (six files, 4 KB), with my earlier findings in the prompt.
The statements now name the function: "For any prediction function $\predfn$ with $\E{\predfnf{\Predvar}^2} &lt; \infty$" in lem-cross-term-zero, thm-risk-decomposition and thm-best-predictor, "Among prediction functions $\predfn$ with ..." in cor-best-predictor-argmin, and "of a prediction function $\predfn$" in def-prediction-error and def-squared-error-risk; the first mention in thm-best-predictor is now linked.
The model reported that each statement is right and found no remaining place in these files that names f(X) as the prediction function.
Nothing was rendered.

Findings

  1. The second link in thm-best-predictor repeats the first (a nit).
    "for the prediction function that uses it" is followed by "Then for any prediction function $\predfn$" in the next sentence; with the first mention linked, the second can be plain text.
  2. The ISLR citation is still unchecked.
    I did not download the book (a 13 MB PDF from the authors' site) because that needs Ezra's go-ahead, so "Section 2.1.1, p. 18" for the name "reducible error" is not verified; my recollection is that the section starts on page 17 and the formula that defines the term is on page 19, so check the page before this merges.

Verdict

VERDICT: FINDINGS

Reviewed-Commit: 8165b50

Posted by Claude Code (AI agent) --- not written by a human.

…a constant prediction function, and avoid a doubled link in thm-best-predictor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWgYrE7LQ7q9Lw5qkHaNiT
…examples

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWgYrE7LQ7q9Lw5qkHaNiT
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dem-extra1

Copy link
Copy Markdown
Contributor

🤖 Antigravity agent report

Cross-harness review (delta-focused, Gemini 3.8 Flash (Medium) via Antigravity agy 1.3.5, standing in while Argon quota is exhausted, read-only plan mode) at 9e430d7

This supersedes my read of 8165b50 and covers the compare 8165b50...9e430d7 (four files), with my earlier items in the prompt.
Fixed: thm-best-predictor links only the first "prediction function"; cor-best-predictor-unique now says "Every prediction function $\predfn$ with $\E{\predfnf{\Predvar}^2} &lt; \infty$"; and both best-predictor examples call f1 a "constant [prediction function]" with f1(X) = 3.
The numbers are right: the conditional mean has risk 1, f1 has risk 5 and f2 has risk 2, so the reducible risks are 5 - 1 = 4 and 2 - 1 = 1 by the risk decomposition.
Nothing was rendered.

Findings

  1. The reducible-risk example mixes the two terms in one sentence.
    _exm-reducible-risk.qmd now reads "the constant [prediction function] $\predfn_1$, with $\predfn_1\paren{\Predvar} = 3$, has [reducible risk] $5 - 1 = 4$, and the prediction $\predfn_2\paren{\Predvar} = 4\Predvar$ has reducible risk $2 - 1 = 1$", so f1 is a prediction function and f2 is a "prediction", although both have a reducible risk, which belongs to the function.
    Write "and $\predfn_2\paren{\Predvar} = 4\Predvar$ has reducible risk $2 - 1 = 1$" (as _exm-best-predictor-argmin.qmd does) or "the prediction function $\predfn_2$, with $\predfn_2\paren{\Predvar} = 4\Predvar$,".
  2. The ISLR citation is still unchecked.
    I have asked Ezra for permission to download the book to check "Section 2.1.1, p. 18"; until he answers, the sentence stays unverified.

Verdict

VERDICT: FINDINGS

Reviewed-Commit: 9e430d7

Posted by Claude Code (AI agent) --- not written by a human.

…example

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FWgYrE7LQ7q9Lw5qkHaNiT
@github-actions

Copy link
Copy Markdown
Contributor

Claude finished review — View run


I fetched PR #291 live just now. It is open, not a draft, and not merged. Its head is 3f59df201c2877cd392d8105c12a03829ac43917, the commit I reviewed, so the review above applies to the current head.

Verdict

Ready for merge

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "3f59df201c2877cd392d8105c12a03829ac43917",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "Commit 3f59df2 rewrites one line in _subfiles/_exm-reducible-risk.qmd so predfn_2 is described as a prediction function, matching predfn_1; macros, links and values are unchanged.",
  "holistic_assessment": "The change is minimal and wording-only, anchors and scope are intact, and the prior Ready for merge verdict stands, with only non-blocking stale def-prediction links remaining elsewhere."
}

Stopping Point: Clean stopping point reached --- session done; UMS executed; no follow-up items pending

Reviewed commit: 3f59df2

@github-actions

Copy link
Copy Markdown
Contributor

💰 Cost: $0.2065 (review) — run

@dem-extra1

Copy link
Copy Markdown
Contributor

🤖 Antigravity agent report

Cross-harness review (delta-focused, Gemini 3.8 Flash (Medium) via Antigravity agy 1.3.5, standing in while Argon quota is exhausted, read-only plan mode) at 3f59df2

This supersedes my read of 9e430d7 and covers the compare 9e430d7...3f59df2 (one hunk in _exm-reducible-risk.qmd), with my one finding in the prompt.
The second clause now reads "and the prediction function $\predfn_2$, with $\predfn_2\paren{\Predvar} = 4\Predvar$, has reducible risk $2 - 1 = 1$", which matches the first clause (the numbers are right: the conditional mean has risk 1, f1 has risk 5 and f2 has risk 2).
The model reported that the edit is correct and consistent, and that nothing else changed; it found nothing.
I read the hunk and agree.
Nothing was rendered.

One open item is not a defect in this diff: the citation "Section 2.1.1, p. 18" for ISLR's "reducible error" in _rem-reducible-risk-notes.qmd is still unchecked, because I have asked Ezra for permission to download the book and have not had an answer.

Verdict

VERDICT: CLEAN

Reviewed-Commit: 3f59df2

Posted by Claude Code (AI agent) --- not written by a human.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.

2026-10-31 04:19 UTC

@d-morrison
d-morrison merged commit 6d0e693 into main Oct 31, 2026
36 checks passed
@d-morrison
d-morrison deleted the claude/prediction-function branch October 31, 2026 04:19
@dem-extra1

Copy link
Copy Markdown
Contributor

🤖 Antigravity agent report

Citation check for _rem-reducible-risk-notes.qmd (after merge)

This follows my read of 3f59df2, where the ISLR citation was the one unchecked item.
I read the book: the corrected June 2023 PDF of the 2nd edition from the lab's mlr repository (Ezra pointed me there after approving the download), converted to text with pdftotext; page numbers are the printed ones.

  • Section 2.1.1 "Why Estimate f?" starts on p. 17.
  • The term "reducible error" is introduced on p. 18 ("which we will call the reducible error and the irreducible error").
  • The squared difference [f(X) - f^(X)]^2 is labelled "Reducible" in equation (2.3) on p. 19.

The section is right, but "p. 18" gives the name and not the squared difference that the sentence attributes to it; the locator should be "Section 2.1.1, pp. 18--19".
This PR is already merged, so I filed pds#303 for the one-line fix.

Posted by Claude Code (AI agent) --- not written by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants