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.
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/
Project details
Release history Release notifications | RSS feed
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.0b0.tar.gz
(209.7 kB
view details)
Built Distribution
File details
Details for the file polars_loess-0.1.0b0.tar.gz
.
File metadata
- Download URL: polars_loess-0.1.0b0.tar.gz
- Upload date:
- Size: 209.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f551676a1de2b4e70ab47d8e97be2b38e44cab6fe8fceddbf821d3f50a685e5 |
|
MD5 | a55caf57ab9948d2193714c4237a40da |
|
BLAKE2b-256 | 5d054ce8507ebd7107034add9347678ac8b1ba7b55851e9077e139a3cdf6c31c |
File details
Details for the file polars_loess-0.1.0b0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: polars_loess-0.1.0b0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37bd0f377b4549df638e603115ad132e8c62b3e026e3b6d07fd15fa95bc6fa3 |
|
MD5 | 8d90e722fabf459635bb6b0dacea9f2c |
|
BLAKE2b-256 | adc73b54c6dbbb4bbba33397dd78febcbd81496bad56a897f26ff68bb214762c |