elbow_helper.segmented module
Phase 6 — slope contrast and broken-line model confirmation.
Confirms a candidate knee three ways: a robust (Theil-Sen) slope change across
it, a continuous broken-line fit that beats a single line on blocked
cross-validation, and a decisive BIC improvement. All NumPy; the broken-line
term c * max(0, x - k) guarantees continuity at the knee.
- elbow_helper.segmented.confirm_segmented_model(prepared, knee_x_norm, config)[source]
Test whether a broken line at
knee_x_normis genuinely better.- Parameters:
prepared (PreparedCurve) – The normalized curve.
knee_x_norm (float) – Candidate knee location in
[0, 1].config (RobustKneeConfig) – Slope/CV/BIC thresholds.
- Returns:
Slope contrast, both slopes, BIC and CV improvements, and a pass flag (with a reason code when it fails).
- Return type: