$npx skillfedfor your agent

pwlf

fit piecewise linear functions to data

Worth itPyPI MathematicsReleased Jul 2026265.8K downloads / moMIT LicensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pwlf-2.6.0-py3-none-any.whl
v2.6.0 · released 2026-07-17 · Python >3.5 · 2 runtime deps: numpy, scipy

Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT License. It solves a specific numerical problem—fitting piecewise linear functions—with a clean API and multiple optimization strategies. Install it if you need to model data with distinct linear regimes or approximate nonlinear relationships with continuous piecewise linear segments.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low friction install with only numpy and scipy as runtime dependencies.
  • Actively maintained with a recent release 28 days ago and 352 repository stars.

License · maintenance · safety

MIT License (permissive) — MIT License permits unrestricted use, modification, and distribution in proprietary and open-source projects without attribution requirement.

last release 2026-07-17 (28 days) · last repo commit 2026-07-17 · 352 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 265,750 downloads/mo, #8,315 on PyPI

Verify before relying

pip install pwlf
import pwlf
my_pwlf = pwlf.PiecewiseLinFit(x_data, y_data)
my_pwlf.fit(number_of_segments)
  • Whether the library handles edge cases like constant-valued segments or single-point data gracefully
  • Performance characteristics on datasets with very large numbers of observations
  • Whether weighted fits support negative or zero weights and how they are normalized
Same gist for agents: .md · .json

What it is and what it does

pwlf is a Python library for fitting continuous piecewise linear functions to data using least squares optimization. You specify how many line segments you want, provide your x-y data, and the library finds the optimal breakpoint locations and segment slopes that minimize residuals. It uses scipy's differential evolution algorithm by default for global optimization, but also offers a faster multi-start gradient-based approach and supports custom optimization routines.

The library handles several fitting scenarios: automatic breakpoint discovery for a specified number of segments, fitting with known breakpoint locations, and weighted regression. It depends on numpy and scipy for numerical computation and linear algebra. The underlying mathematics are based on least squares formulation with global optimization to locate breakpoints, making it suitable for data that exhibits piecewise-linear behavior across different regions.

Use it for

  • Detect and model regime changes in time-series data where behavior shifts between distinct linear trends
  • Approximate nonlinear curves with continuous piecewise linear segments for interpretability and computational efficiency
  • Fit material stress-strain curves or other physical phenomena exhibiting multiple linear regions with known transition points
  • Perform change-point analysis in experimental or observational data to identify where relationships between variables shift
  • Build reduced-order models of complex systems by segmenting the input domain and fitting linear approximations per segment

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

The package is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT License. It solves a specific numerical problem—fitting piecewise linear functions—with a clean API and multiple optimization strategies. Install it if you need to model data with distinct linear regimes or approximate nonlinear relationships with continuous piecewise linear segments.

Install

pwlf on PyPI

Before you install

Low friction install with only numpy and scipy as runtime dependencies. Actively maintained with a recent release 28 days ago and 352 repository stars.

License in practice

MIT License permits unrestricted use, modification, and distribution in proprietary and open-source projects without attribution requirement.

Quickstart

pip install pwlf
import pwlf
my_pwlf = pwlf.PiecewiseLinFit(x_data, y_data)
my_pwlf.fit(number_of_segments)

Verify before relying

  • Whether the library handles edge cases like constant-valued segments or single-point data gracefully
  • Performance characteristics on datasets with very large numbers of observations
  • Whether weighted fits support negative or zero weights and how they are normalized

Package facts

LicenseMIT License permissive
Python supportSupports the current Python release >3.5
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
numpyscipy
MaintenanceActively maintained 28 days since the last release
Last repo commit
First released
Downloads265,750 / month, #8,315 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Programming Language :: Python :: 3

Evidence: pwlf-2.6.0-py3-none-any.whl

Tags

Capabilities
piecewise linear regressionfit segmented lines to datacontinuous piecewise linear functionbreakpoint detection fittingmulti-segment linear regressionpwlf curve fittingleast squares piecewise fit
Topics
curve-fittingoptimizationregression

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 › “piecewise linear regression”

  • pwlfFits continuous piecewise linear functions to data by specifying the…
  • aplrAPLR builds interpretable regression and classification models using…
  • piecewise-regressionFits piecewise linear regression models to data with one or more…

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 lmfit · piecewise-regression · ropwr · aplr · spglm · linearmodels · powerlaw · polars-ols · piecewise-rational · lineax