polars-loess


Namepolars-loess JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryLOESS algorithm for Polars
upload_time2024-10-06 15:27:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords polars loess regression smoothing data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Polars Loess

This is a loess local regression (locally estimated scatterplot smoothing) implementation in Rust for Polars.

**This is an early release. There is room for improvement in terms of performance, memory efficiency and feature set.
I value feedback from the community to see where to go next.**

## Installation

```bash
pip install polars-loess
```

## API

```python
loess(
    'x-column',     # Name of the existing x-values
    'y-column',     # Name of the existing y-values
    'new-x-column', # Name of the new x values. y-values are interpolated for these x-values using loess
    
    # Optional float to specify the fraction of the data used in each local regression.
    # Exactly one of frac or points must be specified.
    frac=None,
    
    # Optional integer to specify the number of points used in each local regression.
    # Exactly one of frac or points must be specified.
    points=None,
    
    # Optional integer to specify the degree of the polynomial used in each local regression.
    # Default is 1.
    degree=None,
)
```


## Example

```python
import polars as pl
from polars_loess import loess

df = pl.DataFrame({
    'time': [
        0.5578196, 2.0217271, 2.5773252, 3.4140288, 4.3014084,
        4.7448394, 5.1073781, 6.5411662, 6.7216176, 7.2600583,
        8.1335874, 9.1224379, 11.9296663, 12.3797674, 13.2728619,
        14.2767453, 15.3731026, 15.6476637, 18.5605355, 18.5866354
    ],
    'price': [
        18.63654, 103.49646, 150.35391, 190.51031, 208.70115,
        213.71135, 228.49353, 233.55387, 234.55054, 223.89225,
        227.68339, 223.91982, 168.01999, 164.95750, 152.61107,
        160.78742, 168.55567, 152.42658, 221.70702, 222.69040,
    ],
})
result = df.with_columns(loess = loess('time', 'price', 'time', frac=0.5))
print(result)
```

Another example can be found in `run.py`. The result looks like.

![Loess example](https://gitlab.sauerburger.com/frank/polars-loess/-/raw/main/example.png)

## Acknowledgements


* The loess implementation is based on https://github.com/joaofig/loess-rs
* The Python bindings are based on https://marcogorelli.github.io/polars-plugins-tutorial/


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "polars-loess",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "polars, loess, regression, smoothing, data",
    "author": null,
    "author_email": "Frank Sauerburger <frank@sauerburger.com>",
    "download_url": "https://files.pythonhosted.org/packages/05/2a/ef7f8601878d88af75186cfa125e1cd59ddb3837cb95727468cbe4f2bd73/polars_loess-0.1.1.tar.gz",
    "platform": null,
    "description": "# Polars Loess\n\nThis is a loess local regression (locally estimated scatterplot smoothing) implementation in Rust for Polars.\n\n**This is an early release. There is room for improvement in terms of performance, memory efficiency and feature set.\nI value feedback from the community to see where to go next.**\n\n## Installation\n\n```bash\npip install polars-loess\n```\n\n## API\n\n```python\nloess(\n    'x-column',     # Name of the existing x-values\n    'y-column',     # Name of the existing y-values\n    'new-x-column', # Name of the new x values. y-values are interpolated for these x-values using loess\n    \n    # Optional float to specify the fraction of the data used in each local regression.\n    # Exactly one of frac or points must be specified.\n    frac=None,\n    \n    # Optional integer to specify the number of points used in each local regression.\n    # Exactly one of frac or points must be specified.\n    points=None,\n    \n    # Optional integer to specify the degree of the polynomial used in each local regression.\n    # Default is 1.\n    degree=None,\n)\n```\n\n\n## Example\n\n```python\nimport polars as pl\nfrom polars_loess import loess\n\ndf = pl.DataFrame({\n    'time': [\n        0.5578196, 2.0217271, 2.5773252, 3.4140288, 4.3014084,\n        4.7448394, 5.1073781, 6.5411662, 6.7216176, 7.2600583,\n        8.1335874, 9.1224379, 11.9296663, 12.3797674, 13.2728619,\n        14.2767453, 15.3731026, 15.6476637, 18.5605355, 18.5866354\n    ],\n    'price': [\n        18.63654, 103.49646, 150.35391, 190.51031, 208.70115,\n        213.71135, 228.49353, 233.55387, 234.55054, 223.89225,\n        227.68339, 223.91982, 168.01999, 164.95750, 152.61107,\n        160.78742, 168.55567, 152.42658, 221.70702, 222.69040,\n    ],\n})\nresult = df.with_columns(loess = loess('time', 'price', 'time', frac=0.5))\nprint(result)\n```\n\nAnother example can be found in `run.py`. The result looks like.\n\n![Loess example](https://gitlab.sauerburger.com/frank/polars-loess/-/raw/main/example.png)\n\n## Acknowledgements\n\n\n* The loess implementation is based on https://github.com/joaofig/loess-rs\n* The Python bindings are based on https://marcogorelli.github.io/polars-plugins-tutorial/\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "LOESS algorithm for Polars",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://gitlab.sauerburger.com/frank/polars-loess"
    },
    "split_keywords": [
        "polars",
        " loess",
        " regression",
        " smoothing",
        " data"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7ce70baedf5563dd3cfe846b66626728b7004e89c97534d08aa9a7994c029a08",
                "md5": "293865b34d814f5db98876748bb4dcb6",
                "sha256": "89e7d8e225414c3d8a01b8174204d54905522463211caab35b6ac7d73a1f0748"
            },
            "downloads": -1,
            "filename": "polars_loess-0.1.1-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "293865b34d814f5db98876748bb4dcb6",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.9",
            "size": 3192109,
            "upload_time": "2024-10-06T15:34:34",
            "upload_time_iso_8601": "2024-10-06T15:34:34.350386Z",
            "url": "https://files.pythonhosted.org/packages/7c/e7/0baedf5563dd3cfe846b66626728b7004e89c97534d08aa9a7994c029a08/polars_loess-0.1.1-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "071ec3c26d9369ec8145da2f33478683fcc2cb829263ee6c517a7f3fe3deb66c",
                "md5": "76d14bbf6c7b0fb454a53b51cfa35a1e",
                "sha256": "3d5648bbeab1bc4112a7bb85d6d6c49d8b19935ac0f6ed6f0232e0b000546961"
            },
            "downloads": -1,
            "filename": "polars_loess-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "76d14bbf6c7b0fb454a53b51cfa35a1e",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.9",
            "size": 3946714,
            "upload_time": "2024-10-06T15:27:37",
            "upload_time_iso_8601": "2024-10-06T15:27:37.792304Z",
            "url": "https://files.pythonhosted.org/packages/07/1e/c3c26d9369ec8145da2f33478683fcc2cb829263ee6c517a7f3fe3deb66c/polars_loess-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "052aef7f8601878d88af75186cfa125e1cd59ddb3837cb95727468cbe4f2bd73",
                "md5": "7d665994b599472462c6ddfa10cf6dc7",
                "sha256": "36be59dd253e0764827dc813d5fef7b52a09c14ec4764e7bbc45732b2d634475"
            },
            "downloads": -1,
            "filename": "polars_loess-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7d665994b599472462c6ddfa10cf6dc7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 209623,
            "upload_time": "2024-10-06T15:27:40",
            "upload_time_iso_8601": "2024-10-06T15:27:40.654283Z",
            "url": "https://files.pythonhosted.org/packages/05/2a/ef7f8601878d88af75186cfa125e1cd59ddb3837cb95727468cbe4f2bd73/polars_loess-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-06 15:27:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "polars-loess"
}
        
Elapsed time: 0.33413s