$npx skillfedfor your agent

piecewise-regression

piecewise (segmented) regression in python

With conditionsPyPI MathematicsReleased Dec 2023133.8K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — piecewise_regression-1.5.0-py3-none-any.whl
v1.5.0 · released 2023-12-18 · 4 runtime deps: numpy, matplotlib, scipy, statsmodels

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

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.
Same gist for agents: .md · .json

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.

With conditions

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

LicenseMIT permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependencies
4 packages
numpymatplotlibscipystatsmodels
MaintenanceDormant 970 days since the last release
Last repo commit
First released
Downloads133,799 / month, #11,495 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone 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

Capabilities
piecewise linear regressionsegmented regression breakpointsfitting lines with breakpointsregression model breakpoint detectionmulti-segment linear fittingchange point regressionsegmented line fitting
Topics
regression-analysisstatistical-modelingbreakpoint-detection

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 Worth it
PyPI · Python Modules · released Dec 2025

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.

BSD-3-Clausepure Python
290.9Mdownloads / mo
kiwisolver Worth it
PyPI · Mathematics · released Mar 2026

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.

BSD-3-Clausecompiled wheel · 3.10+
205.5Mdownloads / mo
sympy Worth it
PyPI · Scientific/Engineering · released Apr 2025

SymPy is a Python library for symbolic mathematics, performing algebraic manipulation, calculus, equation solving, and mathematical expression simplification without numerical approximation.

BSD-3-Clausepure Python · 3.9+
196.4Mdownloads / mo
contourpy Worth it
PyPI · Information Analysis · released Jul 2025

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.

BSD-3-Clausecompiled wheel · 3.11+
191.2Mdownloads / mo
torch With conditions
PyPI · Software Development · released Jul 2026

PyTorch provides GPU-accelerated tensor computation and automatic differentiation for building and training deep neural networks in Python.

Apache-2.0 AND Apache-2.0 WITH LLVM-exception AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND MITcompiled wheel · 3.10+
102.5Mdownloads / mo
onnxruntime Worth it
PyPI · Software Development · released Jul 2026

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.

MITcompiled wheel · 3.11+
89.3Mdownloads / mo

See also aplr · pwlf · ropwr · bootstrapped · lmfit · linearmodels · piecewise-rational · forestci · powerlaw · betacal