elbow_helper.pipeline module

Phase 9 — the public robust_knee orchestration.

Chains preprocessing -> inner search -> segmented confirmation -> bootstrap -> null test, short-circuiting to an explicit NoClearKnee at the first gate that fails and accumulating diagnostics at every stage. Only a candidate that survives all gates is returned as a ClearKnee.

Author

Warith Harchaoui, <warith.harchaoui@deraison.ai>

elbow_helper.pipeline.robust_elbow(x, y=None, config=None)[source]

Convenience wrapper for the classic convex-decreasing elbow.

Equivalent to robust_knee() with curve="convex" and direction="decreasing", the k-means inertia / scree-plot case. y may be omitted, as in robust_knee().

Parameters:

config (RobustKneeConfig | None)

Return type:

KneeResult

elbow_helper.pipeline.robust_knee(x, y=None, curve=None, direction=None, config=None)[source]

Detect a knee conservatively or abstain with a reason.

Parameters:
  • x (array-like) – The curve: x[i] maps to y[i]. x need not be sorted or unique; preprocessing handles cleaning, sorting, deduplication and normalization. y may be omitted, in which case x is taken to be the sequence of y-values alone and the implicit x-axis 0, 1, ..., n-1 is used.

  • y (array-like) – The curve: x[i] maps to y[i]. x need not be sorted or unique; preprocessing handles cleaning, sorting, deduplication and normalization. y may be omitted, in which case x is taken to be the sequence of y-values alone and the implicit x-axis 0, 1, ..., n-1 is used.

  • curve (str, optional) – "concave" (knees) or "convex" (elbows). If omitted, inferred from the data: a curve lying above the chord connecting its endpoints is concave, below is convex.

  • direction (str, optional) – "increasing" or "decreasing". If omitted, inferred from the sign of the trend between x and y.

  • config (RobustKneeConfig, optional) – Thresholds and replicate counts. Defaults to RobustKneeConfig.

Returns:

A ClearKnee (with location, 90% interval and diagnostics) or a NoClearKnee (with a reason code and diagnostics).

Return type:

KneeResult