Skip to content

Execution Modes

Choose the right adapter for your use case.

Choose the first row below whose condition applies:

ConditionAdapter
Data too large to fit in memoryStreaming
Fits in memory, need real-time/incremental updatesOnline
Fits in memory, no real-time requirementBatch
ModeUse CaseMemoryFeatures
BatchComplete datasetsFullAll features
StreamingLarge files (>100K)ChunkedResiduals, robustness
OnlineReal-time sensorsFixed windowIncremental updates

Adapter Comparison


Standard mode for complete datasets. Supports all features.

  • Dataset fits in memory
  • Need intervals, cross-validation, or diagnostics
  • Processing complete files
const { Lowess } = require('fastlowess-wasm');
const x = Float64Array.from({ length: 100 }, (_, i) => i * 2 * Math.PI / 99);
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const model = new Lowess({
fraction: 0.5,
iterations: 3,
parallel: true,
outputs: ["diagnostics"],
intervals: { confidence: 0.95, prediction: 0.95 }
});
const result = model.fit(x, y);
console.log(`95% CI at midpoint: [${result.confidence_lower[50].toFixed(4)}, ${result.confidence_upper[50].toFixed(4)}]`);
console.log(`R2: ${result.diagnostics.r_squared.toFixed(4)}`);
95% CI at midpoint: [0.0433, 0.1038]
R2: 0.9668

Process large datasets in chunks with configurable overlap.

  • Dataset >100,000 points
  • Memory-constrained environments
  • Batch processing pipelines
ParameterDefaultDescription
chunk_size5000Points per chunk
overlapchunk_size / 10Overlap between chunks
merge_strategy"weighted_average"How to merge overlaps
StrategyBehavior
"average"Average overlapping values
"weighted_average"Distance-weighted blend
"take_first"Keep left chunk values
"take_last"Keep right chunk values
const { StreamingLowess } = require('fastlowess-wasm');
const x = Float64Array.from({ length: 100 }, (_, i) => i * 2 * Math.PI / 99);
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const stream = new StreamingLowess(
{ fraction: 0.3, iterations: 2 },
{ chunk_size: 5000, overlap: 500, merge_strategy: "average" }
);
stream.process_chunk(x, y);
const result = stream.finalize();
console.log(`Smoothed y[0]: ${result.y[0].toFixed(4)}`);
Smoothed y[0]: 0.2578

Incremental updates with a sliding window for real-time data.

  • Data arrives incrementally (sensors, streams)
  • Need real-time smoothed values
  • Fixed memory budget
ParameterDefaultDescription
window_capacity1000Max points in window
min_points2Points before output starts
update_mode"incremental"Update strategy
ModeBehaviorSpeed
"incremental"Update only affected fitsFaster
"full"Recompute entire windowMore accurate
const { OnlineLowess } = require('fastlowess-wasm');
const x = Float64Array.from({ length: 100 }, (_, i) => i * 2 * Math.PI / 99);
const y = Float64Array.from(x, xi => Math.sin(xi) + 0.1);
const online = new OnlineLowess(
{ fraction: 0.2 },
{ window_capacity: 100, min_points: 5, update_mode: "incremental" }
);
let shown = 0;
for (let i = 0; i < x.length && shown < 5; i++) {
const result = online.add_point(x[i], y[i]);
if (result !== null) {
console.log(result.y);
shown++;
}
}
0.3511479871810792
0.4120334456984871
0.4716624556603275
0.5297949120891716
0.5861967361004687

FeatureBatchStreamingOnline
Confidence intervals✓✗✗
Prediction intervals✓✗✗
Cross-validation✓✗✗
Diagnostics✓✓✗
Residuals✓✓✓
Robustness weights✓✓✓
Parallel execution✓✓✗