← Back to Pull requests

[objective] Bound the Poisson and Cox intercepts away from zero #12864

Closed
unknown closed this pull request without merging on Nov 17, 2026 14:07 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 09:37 UTC
Author

count:poisson and survival:cox turn base_score into a margin with log, so a negative base_score (or zero for Cox) gives NaN predictions:

import numpy as np
import xgboost as xgb

X = np.random.default_rng(0).normal(size=(200, 4))
dtrain = xgb.DMatrix(X, label=np.arange(1, 201, dtype=np.float32))
for params in (
    {"objective": "count:poisson", "base_score": -0.5},
    {"objective": "survival:cox", "base_score": -1.0},
    {"objective": "survival:cox", "base_score": 0.0},
):
    booster = xgb.train(params, dtrain, 3)
    print(params, booster.predict(dtrain)[:2])  # [nan nan]

This bounds the intercept away from zero before the log, as #12848 did for reg:tweedie, so there is no host-side validation. For Cox, base_score is only ever user-provided (it isn't estimated), so only invalid values change.

For Poisson, all-zero labels give a zero estimated intercept. That used to become a -inf margin with predictions of exactly 0; with the bound the predictions are about 1e-6, as with Tweedie since #12848.

Tests:

  • TestPoissonRegressionBasic and TestCoxRegressionGPair check that a zero and a negative intercept give log(kRtEps).

  • test_non_positive_base_score in tests/python/test_intercept.py trains with each of the values above and checks that the predictions are finite. It fails on master (NaN predictions in all three cases).
  • tests/python/test_intercept.py, test_basic_models.py and the C++ Objective.* tests pass locally (CPU build), and ruff and clang-format are clean on the changed files.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01BkmCTWMg2it3bqF24WKx9m

    Diff: 210 lines (+157 / -53) across 2 files Reviewer: trivialfis Review duration: 270m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 210 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.320
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #12864"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 14.4% · Safe to merge
    14.4%
    Repository