Skip to main content

LOESS algorithm for Polars

Project description

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

pip install polars-loess

API

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

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

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_loess-0.1.1.tar.gz (209.6 kB view details)

Uploaded Source

Built Distributions

polars_loess-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

polars_loess-0.1.1-cp38-abi3-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

File details

Details for the file polars_loess-0.1.1.tar.gz.

File metadata

  • Download URL: polars_loess-0.1.1.tar.gz
  • Upload date:
  • Size: 209.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.1

File hashes

Hashes for polars_loess-0.1.1.tar.gz
Algorithm Hash digest
SHA256 36be59dd253e0764827dc813d5fef7b52a09c14ec4764e7bbc45732b2d634475
MD5 7d665994b599472462c6ddfa10cf6dc7
BLAKE2b-256 052aef7f8601878d88af75186cfa125e1cd59ddb3837cb95727468cbe4f2bd73

See more details on using hashes here.

File details

Details for the file polars_loess-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_loess-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d5648bbeab1bc4112a7bb85d6d6c49d8b19935ac0f6ed6f0232e0b000546961
MD5 76d14bbf6c7b0fb454a53b51cfa35a1e
BLAKE2b-256 071ec3c26d9369ec8145da2f33478683fcc2cb829263ee6c517a7f3fe3deb66c

See more details on using hashes here.

File details

Details for the file polars_loess-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_loess-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89e7d8e225414c3d8a01b8174204d54905522463211caab35b6ac7d73a1f0748
MD5 293865b34d814f5db98876748bb4dcb6
BLAKE2b-256 7ce70baedf5563dd3cfe846b66626728b7004e89c97534d08aa9a7994c029a08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page