Skip to main content

pwlreg

Tests codecov

A scikit-learn-compatible implementation of Piecewise Linear Regression

Installation

pip install pwlreg

Documentation

See the documentation here.

import numpy as np
import matplotlib.pyplot as plt

import pwlreg as pw


x = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
y = np.array([1., 1.5, 0.5, 1., 1.25, 2.75, 4, 5.25, 6., 8.5])

m = pw.AutoPiecewiseRegression(n_segments=2, degree=[0, 1])
m.fit(x, y)

xx = np.linspace(1, 10, 100)
plt.plot(x, y, "o")
plt.plot(xx, m.predict(xx), "-")
plt.show()

pwlreg toy example

m.coef_         # [ 1.00  -5.50  1.35 ]
m.breakpoints_  # [ 1.000000  4.814815  10.000000 ]

$$ x = \begin{cases} 1, & 1 \leq x < 4.815 \ -5.5 + 1.35x, & 4.815 \leq x < 10 \end{cases} $$

Release files for pwlreg 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pwlreg 1.0.3
File Size Uploaded
pwlreg-1.0.3.tar.gz 240.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pwlreg 1.0.3
File Interpreter ABI Platform
pwlreg-1.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 247.6 kB

Release files / pwlreg-1.0.3.tar.gz

Download URL pwlreg-1.0.3.tar.gz
Size 240.0 kB
Tags Source
SHA-256 checksum
How to use checksums
543c4e007d4449c58a1382d2a794270ee9b2272f613ba12c4cee4c652e4a0366
BLAKE2b-256 checksum
How to use checksums
777f448c8fbb0366c82ddb0e8b89909980af8b8e50dc89996f395ed904d3edb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release files / pwlreg-1.0.3-py2.py3-none-any.whl

Download URL pwlreg-1.0.3-py2.py3-none-any.whl
Size 7.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ce4343b322e594e9a2e09a5fecee15a4bc0b031e5208d893e33735cb810dbbc0
BLAKE2b-256 checksum
How to use checksums
6ca068307f4c841df83c4a83b3b1445353469c82b8fd4b4d80c5477d406959e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 28, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page