Skip to content

Fix uniform sample weight knot placement#15

Merged
jxudata merged 1 commit into
mainfrom
feature/sample-weight-fit
May 26, 2026
Merged

Fix uniform sample weight knot placement#15
jxudata merged 1 commit into
mainfrom
feature/sample-weight-fit

Conversation

@jxudata
Copy link
Copy Markdown
Collaborator

@jxudata jxudata commented May 26, 2026

Summary

Fixes weighted knot placement so uniform nonzero sample_weight values preserve the same interpolated quantiles as the unweighted path.

Root Cause

The weighted quantile path used a step-CDF lookup for all weighted calls. Passing sample_weight=np.ones(n) therefore changed knot placement relative to sample_weight=None, which could change the spline basis and fitted predictions for a semantic no-op.

Changes

  • Validate sample-weight shape before fitting.
  • Validate _weighted_quantile weight shape directly.
  • Ignore zero-weight samples for knot placement.
  • Delegate to np.quantile for uniform nonzero weights to preserve NumPy interpolation.
  • Add regression coverage for uniform-weight quantiles, knot placement, and 2-D sample-weight validation.

Validation

  • Local: PYTHONPATH=src pytest -> 133 passed, 1 xfailed
  • GitHub Actions: Python 3.9, 3.10, 3.11, and 3.12 all passed

@jxudata jxudata force-pushed the feature/sample-weight-fit branch from 5ee5608 to fe2636c Compare May 26, 2026 16:05
@jxudata jxudata marked this pull request as ready for review May 26, 2026 16:05
@jxudata jxudata changed the title Add sample_weight support to spline fitting Fix uniform sample weight knot placement May 26, 2026
@jxudata jxudata merged commit fccb607 into main May 26, 2026
4 checks passed
@jxudata jxudata deleted the feature/sample-weight-fit branch May 26, 2026 16:13
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.

1 participant