pwlreg


Namepwlreg JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/ensley-nexant/pwlreg
SummaryA scikit-learn-compatible implementation of Piecewise Linear Regression
upload_time2023-12-26 23:01:56
maintainer
docs_urlNone
authorJohn Ensley
requires_python>=3.10,<4.0
licenseApache-2.0
keywords piecewise regression scikit-learn sklearn change point
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pwlreg

[![Tests](https://github.com/ensley-nexant/pwlreg/actions/workflows/tests.yml/badge.svg)](https://github.com/ensley-nexant/pwlreg/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/ensley-nexant/pwlreg/branch/main/graph/badge.svg?token=x8l1hx77eL)](https://codecov.io/gh/ensley-nexant/pwlreg)

A scikit-learn-compatible implementation of Piecewise Linear Regression

## Installation

```
pip install pwlreg
```

## Documentation

[See the documentation here](https://ensley-nexant.github.io/pwlreg/).


```python
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](docs/img/img.png)

```python
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}
$$


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ensley-nexant/pwlreg",
    "name": "pwlreg",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "piecewise regression,scikit-learn,sklearn,change point",
    "author": "John Ensley",
    "author_email": "jensley@resource-innovations.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/c3/649b05aff3ad95ad02f6f32386bcee7f3e5c9d4e1369e86244caf4b3257d/pwlreg-1.0.1.tar.gz",
    "platform": null,
    "description": "# pwlreg\n\n[![Tests](https://github.com/ensley-nexant/pwlreg/actions/workflows/tests.yml/badge.svg)](https://github.com/ensley-nexant/pwlreg/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/ensley-nexant/pwlreg/branch/main/graph/badge.svg?token=x8l1hx77eL)](https://codecov.io/gh/ensley-nexant/pwlreg)\n\nA scikit-learn-compatible implementation of Piecewise Linear Regression\n\n## Installation\n\n```\npip install pwlreg\n```\n\n## Documentation\n\n[See the documentation here](https://ensley-nexant.github.io/pwlreg/).\n\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nimport pwlreg as pw\n\n\nx = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])\ny = np.array([1., 1.5, 0.5, 1., 1.25, 2.75, 4, 5.25, 6., 8.5])\n\nm = pw.AutoPiecewiseRegression(n_segments=2, degree=[0, 1])\nm.fit(x, y)\n\nxx = np.linspace(1, 10, 100)\nplt.plot(x, y, \"o\")\nplt.plot(xx, m.predict(xx), \"-\")\nplt.show()\n```\n\n![pwlreg toy example](docs/img/img.png)\n\n```python\nm.coef_         # [ 1.00  -5.50  1.35 ]\nm.breakpoints_  # [ 1.000000  4.814815  10.000000 ]\n```\n\n$$\nx =\n\\begin{cases}\n1,            & 1 \\leq x < 4.815 \\\\\n-5.5 + 1.35x, & 4.815 \\leq x < 10\n\\end{cases}\n$$\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A scikit-learn-compatible implementation of Piecewise Linear Regression",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://ensley-nexant.github.io/pwlreg",
        "Homepage": "https://github.com/ensley-nexant/pwlreg",
        "Repository": "https://github.com/ensley-nexant/pwlreg"
    },
    "split_keywords": [
        "piecewise regression",
        "scikit-learn",
        "sklearn",
        "change point"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47971f2125890ef96e2cc02c2c11911482c384e8e4b24d8c7f00bcde5ee082b1",
                "md5": "2969dad5459132d05c1a2c20790caaab",
                "sha256": "4c35abfaf3657b2988addf4b1bf42fedf93de3446645f484df5e5fe5546c79a8"
            },
            "downloads": -1,
            "filename": "pwlreg-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2969dad5459132d05c1a2c20790caaab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 7370,
            "upload_time": "2023-12-26T23:01:54",
            "upload_time_iso_8601": "2023-12-26T23:01:54.745631Z",
            "url": "https://files.pythonhosted.org/packages/47/97/1f2125890ef96e2cc02c2c11911482c384e8e4b24d8c7f00bcde5ee082b1/pwlreg-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddc3649b05aff3ad95ad02f6f32386bcee7f3e5c9d4e1369e86244caf4b3257d",
                "md5": "f319817b2dd3795eb36748153853eb15",
                "sha256": "22145c7e3d18fb4dcdd97cabaf05ebc4e6a73f68bc4db2ee229021eaa8817b35"
            },
            "downloads": -1,
            "filename": "pwlreg-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f319817b2dd3795eb36748153853eb15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7789,
            "upload_time": "2023-12-26T23:01:56",
            "upload_time_iso_8601": "2023-12-26T23:01:56.409028Z",
            "url": "https://files.pythonhosted.org/packages/dd/c3/649b05aff3ad95ad02f6f32386bcee7f3e5c9d4e1369e86244caf4b3257d/pwlreg-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-26 23:01:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ensley-nexant",
    "github_project": "pwlreg",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pwlreg"
}
        
Elapsed time: 0.16210s