Skip to content

StreamingLowess API

See also: fastLowess

  • Dataset >100,000 points
  • Memory-constrained environments
  • Batch processing pipelines

The StreamingLowess class processes data in chunks, suitable for very large datasets or streaming applications.

Constructor:

const { StreamingLowess } = require('fastlowess-wasm');
const stream = new StreamingLowess({ fraction: 0.5 }, { chunk_size: 50, overlap: 10 });
console.log("typeof process_chunk:", typeof stream.process_chunk);
typeof process_chunk: function
  • options: An object containing LowessOptions fields.
  • streamingOptions: An object containing StreamingOptions fields.

Methods:

const { StreamingLowess } = require('fastlowess-wasm');
const n = 100;
const x = Float64Array.from({ length: n }, (_, i) => i * 2 * Math.PI / (n - 1));
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const stream = new StreamingLowess({ fraction: 0.5 }, { chunk_size: 50, overlap: 10 });
const partialResult = stream.process_chunk(x.slice(0, 50), y.slice(0, 50));
console.log("Fraction used:", partialResult.fraction_used);
Fraction used: 0.5
  • Processes a chunk of data. Returns partial results.
const { StreamingLowess } = require('fastlowess-wasm');
const n = 100;
const x = Float64Array.from({ length: n }, (_, i) => i * 2 * Math.PI / (n - 1));
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const stream = new StreamingLowess({ fraction: 0.5 }, { chunk_size: 50, overlap: 10 });
stream.process_chunk(x.slice(0, 50), y.slice(0, 50));
stream.process_chunk(x.slice(50), y.slice(50));
const finalResult = stream.finalize();
console.log("Fraction used:", finalResult.fraction_used);
Fraction used: 0.5
  • Finalizes the smoothing process and returns any remaining buffered results.

Returned by process_chunk() and finalize().

Field Type Description
x Float64Array Sorted x values
y Float64Array Smoothed y values
fraction_used number Fraction used
iterations_used number | undefined Robustness iterations actually performed
residuals Float64Array | undefined Residuals (if return_residuals)
robustness_weights Float64Array | undefined Robustness weights (if return_robustness_weights)
diagnostics Diagnostics | undefined Fit metrics (if return_diagnostics)
dimensions number Number of predictor dimensions

See wasm.md for the full LowessResult field reference.

Field Type Default Description
chunk_size number 5000 Data chunk size
overlap number 500 Overlap between chunks
merge_strategy string "weighted_average" Strategy for blending overlap regions

See: Merge Strategies

Strategy Alias Behavior
"weighted_average" (default) "weighted" Distance-weighted blend
"average" "mean" Average overlapping values
"take_first" "first" Keep left chunk values
"take_last" "last" Keep right chunk values

Merge Strategies