All Projects → cjekel → Piecewise_linear_fit_py

cjekel / Piecewise_linear_fit_py

Licence: mit
fit piecewise linear data for a specified number of line segments

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Piecewise linear fit py

Nptdms
NumPy based Python module for reading TDMS files produced by LabView
Stars: ✭ 138 (-2.13%)
Mutual labels:  numpy, scipy
Data Analysis
主要是爬虫与数据分析项目总结,外加建模与机器学习,模型的评估。
Stars: ✭ 142 (+0.71%)
Mutual labels:  numpy, scipy
Numpycpp
A c++ header library for matrix operation inspired Numpy Scipy, MATLAB only using Eigen.
Stars: ✭ 30 (-78.72%)
Mutual labels:  numpy, scipy
Ml Cheatsheet
A constantly updated python machine learning cheatsheet
Stars: ✭ 136 (-3.55%)
Mutual labels:  numpy, scipy
Ghpythonremote
A two-way connector to use regular Python from IronPython in Rhino/Grasshopper, and vice-versa.
Stars: ✭ 85 (-39.72%)
Mutual labels:  numpy, scipy
Madmom
Python audio and music signal processing library
Stars: ✭ 728 (+416.31%)
Mutual labels:  numpy, scipy
Eulerian Remote Heartrate Detection
Remote heart rate detection through Eulerian magnification of face videos
Stars: ✭ 48 (-65.96%)
Mutual labels:  numpy, scipy
Dsp Theory
Theory of digital signal processing (DSP): signals, filtration (IIR, FIR, CIC, MAF), transforms (FFT, DFT, Hilbert, Z-transform) etc.
Stars: ✭ 437 (+209.93%)
Mutual labels:  numpy, scipy
Docker Alpine Python Machinelearning
Small Docker image with Python Machine Learning tools (~180MB) https://hub.docker.com/r/frolvlad/alpine-python-machinelearning/
Stars: ✭ 76 (-46.1%)
Mutual labels:  numpy, scipy
Dask
Parallel computing with task scheduling
Stars: ✭ 9,309 (+6502.13%)
Mutual labels:  numpy, scipy
Notes Python
中文 Python 笔记
Stars: ✭ 6,127 (+4245.39%)
Mutual labels:  numpy, scipy
Numba Scipy
numba_scipy extends Numba to make it aware of SciPy
Stars: ✭ 98 (-30.5%)
Mutual labels:  numpy, scipy
Cupy
NumPy & SciPy for GPU
Stars: ✭ 5,625 (+3889.36%)
Mutual labels:  numpy, scipy
Human Detection And Tracking
Human-detection-and-Tracking
Stars: ✭ 753 (+434.04%)
Mutual labels:  numpy, scipy
Data Science Ipython Notebooks
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.
Stars: ✭ 22,048 (+15536.88%)
Mutual labels:  numpy, scipy
Mlcourse.ai
Open Machine Learning Course
Stars: ✭ 7,963 (+5547.52%)
Mutual labels:  numpy, scipy
Workshopscipy
A workshop for scientific computing in Python. ( December 2017 )
Stars: ✭ 391 (+177.3%)
Mutual labels:  numpy, scipy
Matchering
🎚️ Open Source Audio Matching and Mastering
Stars: ✭ 398 (+182.27%)
Mutual labels:  numpy, scipy
Ncar Python Tutorial
Numerical & Scientific Computing with Python Tutorial
Stars: ✭ 50 (-64.54%)
Mutual labels:  numpy, scipy
Credit Risk Modelling
Credit Risk analysis by using Python and ML
Stars: ✭ 91 (-35.46%)
Mutual labels:  numpy, scipy

About

A library for fitting continuous piecewise linear functions to data. Just specify the number of line segments you desire and provide the data.

Downloads a month pwlf ci codecov PyPI version

Check out the documentation!

Read the blog post.

Example of a continuous piecewise linear fit to data.

Example of a continuous piecewise linear fit to a sine wave.

Now you can perform segmented constant fitting and piecewise polynomials! Example of multiple degree fits to a sine wave.

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 this example.

Instead of using differential evolution, you can now use a multi-start gradient optimization with fitfast() function. You can specify the number of starting points to use. The default is 2. This means that a latin hyper cube sampling (space filling DOE) of 2 is used to run 2 L-BFGS-B optimizations. See this example which runs fit() function, then runs the fitfast() to compare the runtime differences!

Installation

You can now install with pip.

[sudo] pip install pwlf

Or clone the repo

git clone https://github.com/cjekel/piecewise_linear_fit_py.git

then install with pip

[sudo] pip install ./piecewise_linear_fit_py

How it works

This paper explains how this library works in detail.

This is based on a formulation of a piecewise linear least squares fit, where the user must specify the location of break points. See this post which goes through the derivation of a least squares regression problem if the break point locations are known. Alternatively check out Golovchenko (2004).

Global optimization is used to find the best location for the user defined number of line segments. I specifically use the differential evolution algorithm in SciPy. I default the differential evolution algorithm to be aggressive, and it is probably overkill for your problem. So feel free to pass your own differential evolution keywords to the library. See this example.

Changelog

All changes now stored in CHANGELOG.md

New weights= keyword allows you to perform weighted pwlf fits! Removed TensorFlow code which can now be found here.

Requirements

Python 2.7+

NumPy >= 1.14.0

SciPy >= 1.2.0

pyDOE >= 0.3.8

License

MIT License

Citation

@Manual{pwlf,
author = {Jekel, Charles F. and Venter, Gerhard},
title = {{pwlf:} A Python Library for Fitting 1D Continuous Piecewise Linear Functions},
year = {2019},
url = {https://github.com/cjekel/piecewise_linear_fit_py}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].