Skip to main content

IsotonicRegression

#include <Skigen/Isotonic>

template <typename Scalar = double>
class Skigen::IsotonicRegression(y_min=std::nullopt, y_max=std::nullopt, increasing=`IsotonicIncreasing::True`, out_of_bounds=`OutOfBounds::Nan`)

Univariate monotonic regression with the Pool-Adjacent-Violators algorithm.

Mirrors sklearn.isotonic.IsotonicRegression.

Solves the weighted constrained least-squares problem

miny^  iwi(yiy^i)2subject toy^iy^i+1    i\min_{\hat{y}} \; \sum_i w_i (y_i - \hat{y}_i)^2 \quad \text{subject to} \quad \hat{y}_i \le \hat{y}_{i+1} \;\;\forall i

(the constraint reverses for increasing = False). The fitted function is piecewise-linear; predictions interpolate between adjacent thresholds.



Attributes:

  • y_min : std::optional< Scalar >

  • y_max : std::optional< Scalar >

  • increasing_param : IsotonicIncreasing

  • out_of_bounds : OutOfBounds

  • X_min : Scalar

  • X_max : Scalar

  • X_thresholds : VectorType

  • y_thresholds : VectorType

  • increasing_resolved : bool Effective monotonicity direction after fitting.


Methods

fit(X, y)

Fit the isotonic regression on a 1-D feature.

X must have shape (n_samples, 1). For multi-column X this method throws std::invalid_argument (matching sklearn).


predict(X)

Predict using the fitted piecewise-linear isotonic function.


transform(X)

Convenience: same as predict for sklearn API parity.


score(X, y)

R^2 score on (X, y).