piecewise-regression
piecewise (segmented) regression in python
Decision gist · record as of 2026-08-14
Yes, if you need to fit piecewise linear models with statistical inference. The package is well-maintained enough (last commit mid-2024), has no known vulnerabilities, and low install friction. Dormant status is not a blocker for a stable, narrowly-scoped tool. Install with caution if you require active development or frequent updates; for one-off analysis or established workflows, it is reliable.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with a pure Python wheel and four standard scientific dependencies (numpy, scipy, matplotlib, statsmodels).
- Maintenance is dormant—last release was 2023-12-18 and last commit 2024-06-09—but the repository remains active and unarchived.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2023-12-18 (970 days) · last repo commit 2024-06-09 · 131 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 133,799 downloads/mo, #11,495 on PyPI
Alternatives
Verify before relying
pip install piecewise-regression
import piecewise_regression
import numpy as np
x = np.linspace(0, 20, 100)
y = 100 - 4*x + 2*np.maximum(x - 7, 0) + np.random.normal(size=100)
pw_fit = piecewise_regression.Fit(x, y, n_breakpoints=1)
pw_fit.summary()- Whether the package handles edge cases (e.g., collinear data, very few observations) gracefully or requires specific data characteristics.
- Performance characteristics on large datasets or high-dimensional breakpoint searches.
- Whether bootstrap restarting convergence guarantees improve with specific parameter tuning beyond n_boot.
What it is and what it does
Piecewise-regression implements Muggeo's iterative algorithm to fit piecewise linear models—straight lines with one or more breakpoints where the slope changes. You provide x and y data plus either initial breakpoint guesses or a desired number of breakpoints, and the package estimates the segment gradients, breakpoint positions, and confidence intervals for all parameters. It includes a Davies test to assess whether breakpoints exist statistically.
The package uses bootstrap restarting to escape local optima and improve the chance of finding a global solution, though convergence is not guaranteed. It also offers a ModelSelection tool based on Bayesian Information Criterion (BIC) to compare models with different numbers of breakpoints. Results can be extracted as structured data or plotted with matplotlib for visualization of the fit, breakpoints, and confidence bands.
Use it for
- Detect and quantify shifts in trend in time-series data, such as changes in growth rate before and after a policy intervention.
- Identify optimal threshold points in dose-response or dose-effect studies where biological or physical response changes slope.
- Analyze piecewise relationships in economic or environmental data where structural breaks occur at known or unknown transition points.
- Compare competing segmented models using BIC to select the number of breakpoints that best explains the data.
- Extract confidence intervals around estimated breakpoint positions for hypothesis testing or uncertainty quantification.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to fit piecewise linear models with statistical inference.
The package is well-maintained enough (last commit mid-2024), has no known vulnerabilities, and low install friction. Dormant status is not a blocker for a stable, narrowly-scoped tool. Install with caution if you require active development or frequent updates; for one-off analysis or established workflows, it is reliable.
Install
piecewise-regression on PyPI
Before you install
Low install friction with a pure Python wheel and four standard scientific dependencies (numpy, scipy, matplotlib, statsmodels). Maintenance is dormant—last release was 2023-12-18 and last commit 2024-06-09—but the repository remains active and unarchived.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install piecewise-regression
import piecewise_regression
import numpy as np
x = np.linspace(0, 20, 100)
y = 100 - 4*x + 2*np.maximum(x - 7, 0) + np.random.normal(size=100)
pw_fit = piecewise_regression.Fit(x, y, n_breakpoints=1)
pw_fit.summary()
Verify before relying
- Whether the package handles edge cases (e.g., collinear data, very few observations) gracefully or requires specific data characteristics.
- Performance characteristics on large datasets or high-dimensional breakpoint searches.
- Whether bootstrap restarting convergence guarantees improve with specific parameter tuning beyond n_boot.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagesnumpymatplotlibscipystatsmodels |
| Maintenance | Dormant 970 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 133,799 / month, #11,495 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: piecewise_regression-1.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “segmented regression breakpoints”
- piecewise-regressionFits piecewise linear regression models to data with one or more…
- pwlfFits continuous piecewise linear functions to data by specifying the…
- cuequivariancecuEquivariance provides CUDA-accelerated operations for building…
Give your agent the search over MCP, or paste the wish link into any chat.
More Mathematics packages
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
kiwisolver is a Python binding to a fast C++ implementation of the Cassowary constraint solver, enabling you to solve systems of linear constraints and inequalities.
Install it if you need to solve constraint systems; skip it if you only need simple linear algebra.
SymPy is a Python library for symbolic mathematics, performing algebraic manipulation, calculus, equation solving, and mathematical expression simplification without numerical approximation.
ContourPy calculates contours of 2D quadrilateral grids using C++11 algorithms wrapped in Python, offering serial and multithreaded implementations without requiring Matplotlib as a dependency.
PyTorch provides GPU-accelerated tensor computation and automatic differentiation for building and training deep neural networks in Python.
onnxruntime loads and executes Open Neural Network Exchange (ONNX) models with a focus on inference performance across CPUs and accelerators.
Install it if you have ONNX models to run in production or development.
See also aplr · pwlf · ropwr · bootstrapped · lmfit · linearmodels · piecewise-rational · forestci · powerlaw · betacal