fit piecewise linear functions to data
Maintained. Last release 7 weeks ago, commits in 5 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install pwlfAbout
A library for fitting continuous piecewise linear functions to data. Just specify the number of line segments you desire and provide the data.
Check out the documentation!
Read the blog post.


Now you can perform segmented constant fitting and piecewise polynomials!

Features
For a specified number of line segments, you can determine (and predict from) the optimal continuous piecewise linear function f(x). See this example.
You can fit and predict a continuous piecewise linear function f(x) if you know the specific x locations where the line segments terminate. See this example.
If you want to pass different keywords for the SciPy differential evolution algorithm see this example.
You can use a different optimization algorithm to find the optimal location for line segments by using the objective function that minimizes the sum of square of residuals. See .