Skip to main content

LOESS Project

loess-rs fastLoess PyPI R-universe npm Julia WASM C++
fastloess (Python) libfastloess (C++) rfastloess (R)
CI

One LOESS to Rule Them All
One LOESS to Rule Them All

The fastest, most robust, and most feature-complete language-agnostic LOESS (Locally Estimated Scatterplot Smoothing) implementation for Rust, Python, R, Julia, JavaScript, C++, and WebAssembly.

[!IMPORTANT]

The loess-project contains a complete ecosystem for LOESS smoothing:


Installation

[!NOTE]

Currently available for R, Python, Rust, Julia, Node.js, WebAssembly, and C++. See the Installation Guide for detailed installation instructions.

Documentation

[!NOTE]

📚 View the full documentation


LOESS vs. LOWESS

Feature LOESS (This Crate) LOWESS
Polynomial Degree Linear, Quadratic, Cubic, Quartic Linear (Degree 1)
Dimensions Multivariate (n-D support) Univariate (1-D only)
Flexibility High (Distance metrics) Standard
Complexity Higher (Matrix inversion) Lower (Weighted average/slope)

[!TIP] Note: For a LOWESS implementation, use lowess-project.


Why this package?

Speed

The loess project beats the competition in terms of speed, whether in single-threaded or multi-threaded parallel execution. It is typically 5–20x faster than R's loess in serial mode, and up to 200x faster on large datasets with parallel execution.

For more details on the performance comparison, see the Benchmarks page.

Robustness

This implementation is more robust than R's loess due to two key design choices:

MAD-Based Scale Estimation:

For robustness weight calculations, this crate uses Median Absolute Deviation (MAD) for scale estimation:

s = median(|r_i - median(r)|)

In contrast, R's loess uses the median of absolute residuals (MAR):

s = median(|r_i|)
  • MAD is a breakdown-point-optimal estimator—it remains valid even when up to 50% of data are outliers.
  • The median-centering step removes asymmetric bias from residual distributions.
  • MAD provides consistent outlier detection regardless of whether residuals are centered around zero.

Boundary Padding:

This crate applies a range of different boundary policies at dataset edges:

  • Extend: Repeats edge values to maintain local neighborhood size.
  • Reflect: Mirrors data symmetrically around boundaries.
  • Zero: Pads with zeros (useful for signal processing).
  • NoBoundary: Original Cleveland behavior

R's loess does not apply boundary padding, which can lead to:

  • Biased estimates near boundaries due to asymmetric local neighborhoods.
  • Increased variance at the edges of the smoothed curve.

Features

A variety of features, supporting a range of use cases:

Feature This package R (stats)
Polynomial Degree 5 (0–4) 2 (1 or 2)
Kernel 7 options only Tricube
Robustness Weighting 3 options only Bisquare
Scale Estimation 3 options only MAR
Distance Metric 6 options normalized only
Boundary Padding 4 options no padding
Zero Weight Fallback 3 options no
Auto Convergence yes no
Online Mode yes no
Streaming Mode yes no
Confidence Intervals yes no
Prediction Intervals yes no
Diagnostics (RMSE, R², AIC) yes no
Cross-Validation 2 options no
Parallel Execution yes no
no-std Support yes no

Validation

All implementations are numerical twins of R's loess:

Aspect Status Details
Accuracy ✅ EXACT MATCH Max diff < 1e-12 across all scenarios
Consistency ✅ PERFECT Multiple scenarios pass with strict tolerance
Robustness ✅ VERIFIED Robust smoothing matches R exactly

API Reference

R:

library(rfastloess)

model <- Loess(
    fraction = 0.67,
    iterations = 3L,
    weight_function = "tricube",
    robustness_method = "bisquare",
    zero_weight_fallback = "use_local_mean",
    boundary_policy = "extend",
    scaling_method = "mad",
    confidence_intervals = NULL,
    prediction_intervals = NULL,
    return_diagnostics = FALSE,
    return_residuals = FALSE,
    return_robustness_weights = FALSE,
    cv_fractions = NULL,
    cv_method = "kfold",
    cv_k = 5L,
    auto_converge = NULL,
    parallel = TRUE
)
custom_weights <- rep(1, length(x))
result <- model$fit(x, y, custom_weights = custom_weights)

# Result structure:
result$x,
result$y,
result$standard_errors,
result$confidence_lower,
result$confidence_upper,
result$prediction_lower,
result$prediction_upper,
result$residuals,
result$robustness_weights,
result$diagnostics,
result$iterations_used,
result$fraction_used,
result$cv_scores

Python:

from fastloess import Loess

model = Loess(
    fraction=0.67,
    iterations=3,
    weight_function="tricube",
    robustness_method="bisquare",
    zero_weight_fallback="use_local_mean",
    boundary_policy="extend",
    scaling_method="mad",
    confidence_intervals=None,
    prediction_intervals=None,
    return_diagnostics=False,
    return_residuals=False,
    return_robustness_weights=False,
    cv_fractions=None,
    cv_method="kfold",
    cv_k=5,
    auto_converge=None,
    parallel=True
)
custom_weights = [1.0] * len(x)
result = model.fit(x, y, custom_weights=custom_weights)

# Result structure:
result.x,
result.y,
result.standard_errors,
result.confidence_lower,
result.confidence_upper,
result.prediction_lower,
result.prediction_upper,
result.residuals,
result.robustness_weights,
result.diagnostics,
result.iterations_used,
result.fraction_used,
result.cv_scores

Rust:

use loess_rs::prelude::*;

let model = Loess::new()
    .fraction(0.67)
    .iterations(3)
    .weight_function("tricube")
    .robustness_method("bisquare")
    .zero_weight_fallback("use_local_mean")
    .boundary_policy("extend")
    .scaling_method("mad")
    .confidence_intervals(0.95)
    .prediction_intervals(0.95)
    .return_diagnostics()
    .return_residuals()
    .return_robustness_weights()
    .cv_fractions(vec![0.3, 0.5, 0.7])
    .cv_method("kfold")
    .cv_k(5)
    .cv_seed(123)
    .auto_converge(1e-4)
    .custom_weights(vec![1.0; x.len()])
    .parallel(true)             // fastLoess only
    .build()?;

let result = model.fit(&x, &y)?;

// Result structure:
pub struct LoessResult<T> {
    pub x: Vec<T>,                           // Sorted x values
    pub y: Vec<T>,                           // Smoothed y values
    pub standard_errors: Option<Vec<T>>,
    pub confidence_lower: Option<Vec<T>>,
    pub confidence_upper: Option<Vec<T>>,
    pub prediction_lower: Option<Vec<T>>,
    pub prediction_upper: Option<Vec<T>>,
    pub residuals: Option<Vec<T>>,
    pub robustness_weights: Option<Vec<T>>,
    pub diagnostics: Option<Diagnostics<T>>,
    pub iterations_used: Option<usize>,
    pub fraction_used: T,
    pub cv_scores: Option<Vec<T>>,
}

Julia:

using FastLOESS

model = Loess(;
    fraction=0.67,
    iterations=3,
    weight_function="tricube",
    robustness_method="bisquare",
    zero_weight_fallback="use_local_mean",
    boundary_policy="extend",
    scaling_method="mad",
    confidence_intervals=NaN,
    prediction_intervals=NaN,
    return_diagnostics=false,
    return_residuals=false,
    return_robustness_weights=false,
    cv_fractions=Float64[], # e.g. [0.3, 0.5]
    cv_method="kfold",
    cv_k=5,
    auto_converge=NaN,
    parallel=true
)
custom_weights = ones(length(x))
result = fit(model, x, y; custom_weights=custom_weights)

# Result structure:
result.x,
result.y,
result.standard_errors,
result.confidence_lower,
result.confidence_upper,
result.prediction_lower,
result.prediction_upper,
result.residuals,
result.robustness_weights,
result.diagnostics,
result.iterations_used,
result.fraction_used,
result.cv_scores

Node.js:

import { Loess } from "fastloess"

const model = new Loess({
    fraction: 0.67,
    iterations: 3,
    weight_function: "tricube",
    robustness_method: "bisquare",
    zero_weight_fallback: "use_local_mean",
    boundary_policy: "extend",
    scaling_method: "mad",
    confidence_intervals: 0.95,
    prediction_intervals: 0.95,
    return_diagnostics: true,
    return_residuals: true,
    return_robustness_weights: true,
    cv_fractions: [0.3, 0.5, 0.7],
    cv_method: "kfold",
    cv_k: 5,
    auto_converge: 1e-4,
    parallel: true
})
const custom_weights = Array(x.length).fill(1.0)
const result = model.fit(x, y, custom_weights)

// Result structure:
result.x,
result.y,
result.standard_errors,
result.confidence_lower,
result.confidence_upper,
result.prediction_lower,
result.prediction_upper,
result.residuals,
result.robustness_weights,
result.diagnostics,
result.iterations_used,
result.fraction_used,
result.cv_scores

WebAssembly:

import { Loess } from "fastloess-wasm"

const model = new Loess({
    fraction: 0.67,
    iterations: 3,
    weight_function: "tricube",
    robustness_method: "bisquare",
    zero_weight_fallback: "use_local_mean",
    boundary_policy: "extend",
    scaling_method: "mad",
    confidence_intervals: 0.95,
    prediction_intervals: 0.95,
    return_diagnostics: true,
    return_residuals: true,
    return_robustness_weights: true,
    cv_fractions: [0.3, 0.5, 0.7],
    cv_method: "kfold",
    cv_k: 5,
    auto_converge: 1e-4,
    parallel: true
})
const custom_weights = new Float64Array(x.length).fill(1)
const result = model.fit(x, y, custom_weights)

// Result structure:
result.x,
result.y,
result.standard_errors,
result.confidence_lower,
result.confidence_upper,
result.prediction_lower,
result.prediction_upper,
result.residuals,
result.robustness_weights,
result.diagnostics,
result.iterations_used,
result.fraction_used,
result.cv_scores

C++:

fastloess::LoessOptions options;
options.fraction = 0.67;
options.iterations = 3;
options.weight_function = "tricube";
options.robustness_method = "bisquare";
options.zero_weight_fallback = "use_local_mean";
options.boundary_policy = "extend";
options.scaling_method = "mad";
options.confidence_intervals = 0.95;
options.prediction_intervals = 0.95;
options.return_diagnostics = true;
options.return_residuals = true;
options.return_robustness_weights = true;
options.cv_fractions = {0.3, 0.5, 0.7};
options.cv_method = "kfold";
options.cv_k = 5;
options.auto_converge = 1e-4;
options.parallel = true;

fastloess::Loess model(options);
std::vector<double> custom_weights(x.size(), 1.0);
const auto result = model.fit(x, y, custom_weights).value();

// Result structure:
result.x_vector(),
result.y_vector(),
result.standard_errors(),
result.confidence_lower(),
result.confidence_upper(),
result.prediction_lower(),
result.prediction_upper(),
result.residuals(),
result.robustness_weights(),
result.diagnostics(),
result.iterations_used(),
result.fraction_used(),
result.cv_scores()

Contributing

Contributions are welcome! Please see the Contributing Guide for more information.

Changelog

See the Changelog for a history of changes.

License

Licensed under MIT or Apache-2.0.

Citation

If you use this software in your research, please cite it using the CITATION.cff file or the BibTeX entry below:

@software{loess_project,
  author = {Valizadeh, Amir},
  title = {LOESS Project: High-Performance Locally Estimated Scatterplot Smoothing},
  year = {2026},
  url = {https://github.com/thisisamirv/loess-project},
  license = {MIT OR Apache-2.0}
}

Download files

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

Source Distribution

fastloess-0.9.0.tar.gz (173.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastloess-0.9.0-cp38-abi3-win_amd64.whl (518.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

fastloess-0.9.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.0 kB view details)

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

fastloess-0.9.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (604.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

fastloess-0.9.0-cp38-abi3-macosx_11_0_arm64.whl (569.7 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

fastloess-0.9.0-cp38-abi3-macosx_10_12_x86_64.whl (599.0 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file fastloess-0.9.0.tar.gz.

File metadata

  • Download URL: fastloess-0.9.0.tar.gz
  • Upload date:
  • Size: 173.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastloess-0.9.0.tar.gz
Algorithm Hash digest
SHA256 6ebdeeec9eef65c1fd848de8a53110477e0df916b7cdffa9a1a6020a71d913f0
MD5 884e6a3ed1843f42d7b68505dbcf4704
BLAKE2b-256 4b33873c1d7d2ffdb81635bba5c3f266b72dc5d5bd5141a9c400b0ed5e4eab54

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0.tar.gz:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastloess-0.9.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: fastloess-0.9.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 518.6 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fastloess-0.9.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4a053e252bd97d953e9a6b498044ee078ac3175109a7d8aa8b9948914fd3d3b1
MD5 7b4b200052dd80aec4ec56b7c2ec2520
BLAKE2b-256 974992dca080daab91fbbb22bf92998bbc916baffc2a255332d5e38c9c909e83

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0-cp38-abi3-win_amd64.whl:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastloess-0.9.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastloess-0.9.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f8788a183d26037be0c84415579f046f7b837d458a88dbdd37b097840fc7642
MD5 ca51211ab9ac485717307c08ddee8802
BLAKE2b-256 210c19f129aee2eb627c641a2b2ecde02820a71ee149b65b86b58463cc5f951e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastloess-0.9.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fastloess-0.9.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4e17cfaec32224934d8d1947b6bd47f66ee17a1cca23e1ebb328bc7af8791ed0
MD5 fb9680fccba5998b133c20056f99239e
BLAKE2b-256 f1ade4c7518e4861abb6e368cdead5664531ff3fcbe86274b06696938b59cf53

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastloess-0.9.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastloess-0.9.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3632e8b8536fe3e0fc4f04fd7db121d1882828e1237ea7f63b1892be251060c
MD5 bd7ff5037c43bc2aa9227a36313049a7
BLAKE2b-256 603cdd82b7b5f5b0ce10f0a16d893f0f5fd2db1afe381491a557544d7f91351c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastloess-0.9.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fastloess-0.9.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7abc29bbadccb8cbfc4905fff1ac437b39030693b4965961391b4e0fa65eea87
MD5 489b3d57c113ce7a3827caf421da61de
BLAKE2b-256 4bd94445dd1807114b0b84067d0d83cd25ce53de525fbc9eae1103d119ebced1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastloess-0.9.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release-pypi.yml on thisisamirv/loess-project

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page