← Back to Pull requests

ENH: Add GCV Computation Path for `t != x` #5

Open
unknown opened this pull request with 214 lines diff across 2 files
View on GitHub
unknown unknown commented on Aug 24, 2026 22:34 UTC
Author

Adds automatic smoothing parameter selection to the t= path of make_smoothing_spline: calling with user knots and no lam now selects lam by minimizing the generalized cross-validation (GCV) criterion, matching the behavior of the default t=None path. Previously this raised NotImplementedError.

Builds on the userknots branch (scipy#25862). The derivation of the criterion and the supporting experiments are in the companion report, Sections 12 and 15: https://github.com/aadya940/scipy-bspline-testing

What was added

  • _make_smoothing_spline_user_knots_gcv: minimizes the GCV score over the base-10 logarithm of lam with minimize_scalar(method="bounded"). The log transform is essential: on a linear axis the GCV minimum occupies a vanishing fraction of the search interval and bounded scalar minimizers fail silently.

  • _solve_smoothing_spline_coefficients: shared kernel for both the explicit-lam fit and the GCV objective. One banded solve per evaluation; with compute_trace=True it also returns the trace of the influence matrix, computed from the central bands of the inverse only.

  • _compute_b_inv (the Hutchinson and de Hoog banded partial inverse) hoisted from inside _compute_optimal_gcv_parameter to module level, unchanged, and now shared by the existing t=None GCV path and the new path.

  • The GCV objective returns infinity when the solve reports a numerically singular system, so the search steers around bad lam regions instead of raising mid-optimization.

  • Weights are supported: the criterion uses the weighted residual sum, which is equivalent to unweighted GCV of the rescaled problem (see the assumptions inventory in Section 12 of the report).
  • Diff: 214 lines (+160 / -54) across 2 files Reviewer: aadya940 Review duration: 141224m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 214 lines diff across 2 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.321
    Real PR Conversation Timeline
    1 comments
    "Review active on #5"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.6% (MEDIUM) · Higher = larger blast radius
    43.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.1% · Safe to merge
    24.1%
    Repository