skillfed

ropwr

RoPWR: Robust Piecewise Regression

ropwr v1.2.0 299.8K downloads/30d#7,850 on PyPI14
Permissive license Apache Licence 2.0 AGING released

What it is and what it does

RoPWR is a Python library for robust piecewise polynomial regression that solves constrained optimization problems to fit continuous or discontinuous piecewise polynomials to data. Given a set of split points, it computes optimal coefficients subject to monotonic constraints (e.g., convex, valley, ascending trends) and supports multiple loss functions (L1, L2, Huber, quantile) plus L1 or L2 regularization. The library delegates the underlying optimization to cvxpy, which can use several solvers including CLARABEL, ECOS, OSQP, SCS, and HIGHS, or solves certain formulations directly.

Typical workflow: load data, define or auto-generate split points (using scikit-learn's KBinsDiscretizer), instantiate a RobustPWRegression object with desired constraints and objectives, and call fit(). The library handles prediction bounds (lower/upper limits) and supports both supervised split selection and unsupervised binning strategies (equal-size or equal-frequency intervals).

Use it for:

  • Fit non-linear relationships with known trend structure (e.g., U-shaped or monotonic patterns) to avoid overfitting.
  • Enforce business constraints like monotonicity or convexity in regression models for interpretability.
  • Robust regression on noisy data using Huber loss or L1 objectives instead of least squares.
  • Regularized piecewise fitting to balance model complexity and prediction accuracy.
  • Predict with bounded outputs (e.g., housing prices between lower and upper limits).

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

RoPWR computes optimal piecewise polynomial regression with support for monotonic constraints, multiple objective functions, and regularization, using convex optimization solvers.

Yes, if you need constrained piecewise polynomial regression. The library is well-integrated with scikit-learn and scipy, has low install friction, and carries no known vulnerabilities. However, note the aging maintenance status (last commit January 2026, 203 days ago) and modest popularity (top 15000 tier)—suitable for niche regression tasks but not a mainstream tool.

Install

ropwr on PyPI

pip

pip install ropwr

uv

uv add ropwr

poetry

poetry add ropwr

Installing ropwr

Before you install

Low install friction: pure Python wheel with four well-established scientific dependencies (cvxpy, numpy, scikit-learn, scipy). Last commit 2026-01-23 indicates recent activity, though maintenance status is aging.

License in practice

Apache Licence 2.0 is permissive, allowing commercial and private use with minimal restrictions—suitable for most projects.

Quickstart

pip install ropwr

from ropwr import RobustPWRegression
import numpy as np

pw = RobustPWRegression(objective="l1", degree=1, monotonic_trend="convex")
pw.fit(x, y, splits)

Requires Python >=3.10; cvxpy requires a working solver backend (CLARABEL, ECOS, OSQP, SCS, or HIGHS).

Verify before relying

  • Whether the package is actively maintained beyond the January 2026 commit; aging status suggests possible stagnation.
  • Performance characteristics and scalability limits for large datasets or high-dimensional problems.
  • Availability and quality of documentation beyond the referenced tutorials.

Package facts

License Apache Licence 2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 4 — cvxpy, numpy, scikit-learn, scipy
Maintenance aging — 203 days since the last release
Last repo commit
First released
Downloads 299,845/month — #7,850 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ropwr-1.2.0-py3-none-any.whl

Intended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

piecewise polynomial regressionrobust regression with constraintsconvex optimization regressionmonotonic trend fittingsplit-point regressionpolynomial fitting with boundsregularized piecewise regression
regressionoptimizationpiecewise-polynomial

More Libraries packages