elbow_helper.multi_segmentation module
Phase M1: piecewise-linear segmentation for elbow_helper.robust_knees().
Ported from the validated research/multiknee/segmentation.py (see
research/multiknee/RESULTS.md and ELBOW-en.tex for the derivation and the
empirical comparison against greedy binary segmentation). Segments are
independent OLS lines, not the continuous broken line
elbow_helper.segmented uses for the single-knee pipeline; see
ELBOW-en.tex section 5 for why that difference is deliberate.
- class elbow_helper.multi_segmentation.SegmentCostTable(x, y)[source]
Bases:
objectO(1)-per-query OLS segment cost, via prefix sums of sufficient statistics.
- Parameters:
x (numpy.ndarray) – The curve, already cleaned and sorted by
x.y (numpy.ndarray) – The curve, already cleaned and sorted by
x.
- class elbow_helper.multi_segmentation.Segmentation(breakpoints, boundaries, sse, n)[source]
Bases:
objectA concrete k-breakpoint segmentation of
x, y.- Parameters:
- elbow_helper.multi_segmentation.dp_optimal_partition(x, y, k_max, min_seg=3)[source]
Exact optimal-partitioning DP: the best segmentation for every k = 0..k_max.
See
ELBOW-en.texsection 7 for the recursion and complexity, andresearch/multiknee/RESULTS.mdfor why this is used instead of greedy binary segmentation.- Parameters:
- Returns:
One optimal
Segmentationper achievablekfrom0up tomin(k_max, (n // min_seg) - 1), in increasing order ofk.- Return type:
list of Segmentation