@sipemu/anofox-forecast 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -128
- package/anofox_forecast_js.d.ts +6 -414
- package/anofox_forecast_js.js +16 -896
- package/anofox_forecast_js_bg.wasm +0 -0
- package/anofox_forecast_js_bg.wasm.d.ts +4 -75
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sipemu/anofox-forecast
|
|
2
2
|
|
|
3
|
-
WebAssembly bindings for [anofox-forecast](https://crates.io/crates/anofox-forecast), a comprehensive time series forecasting library with
|
|
3
|
+
WebAssembly bindings for [anofox-forecast](https://crates.io/crates/anofox-forecast), a comprehensive time series forecasting library with 50+ models, automatic model selection, probabilistic postprocessing, and more.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -116,17 +116,6 @@ const ts = TimeSeries.withTimestamps(
|
|
|
116
116
|
| `AutoForecaster` | Best of ARIMA, ETS, Theta | - |
|
|
117
117
|
| `AutoEnsembleForecaster` | Ensemble of top-K models | - |
|
|
118
118
|
|
|
119
|
-
### Orchestration
|
|
120
|
-
|
|
121
|
-
| Type | Description |
|
|
122
|
-
|------|-------------|
|
|
123
|
-
| `JsDataProfile` | Automated data profiling (stationarity, trend, quality) |
|
|
124
|
-
| `JsPipelineBuilder` | Declarative pipeline construction |
|
|
125
|
-
| `JsPipelineResult` | Pipeline result with forecast and diagnostics |
|
|
126
|
-
| `JsPipelineReport` | Structured multi-section report |
|
|
127
|
-
| `selectModels()` | Model recommendation from data profile |
|
|
128
|
-
| `explainResult()` | Human-readable result explanation |
|
|
129
|
-
|
|
130
119
|
## Prediction Intervals
|
|
131
120
|
|
|
132
121
|
Most models support prediction intervals:
|
|
@@ -236,121 +225,6 @@ const pi = processor.predictIntervals(trained, newForecasts);
|
|
|
236
225
|
- `JsPostProcessor` — unified API wrapping all methods
|
|
237
226
|
- `JsBacktestConfig` / `JsBacktestResult` — rolling/expanding window backtesting
|
|
238
227
|
|
|
239
|
-
## Orchestration / Agent Forecasting
|
|
240
|
-
|
|
241
|
-
Build autonomous forecasting pipelines with data profiling, multi-metric model selection, preprocessing, ensemble construction, and structured reporting:
|
|
242
|
-
|
|
243
|
-
### Data Profiling
|
|
244
|
-
|
|
245
|
-
```javascript
|
|
246
|
-
import { JsDataProfile } from '@sipemu/anofox-forecast';
|
|
247
|
-
|
|
248
|
-
// Profile a time series
|
|
249
|
-
const profile = JsDataProfile.fromSeries(ts);
|
|
250
|
-
console.log('Observations:', profile.nObservations);
|
|
251
|
-
console.log('Trend:', profile.trendDirection); // "Rising", "Falling", "Flat"
|
|
252
|
-
console.log('Stationary?', profile.isStationary);
|
|
253
|
-
console.log('Intermittent?', profile.isIntermittent);
|
|
254
|
-
console.log('Quality:', profile.qualityScore); // 0.0 to 1.0
|
|
255
|
-
|
|
256
|
-
// Full profile as JSON
|
|
257
|
-
const json = profile.toJSON();
|
|
258
|
-
|
|
259
|
-
// Profile raw values (no timestamps needed)
|
|
260
|
-
const profile2 = JsDataProfile.fromValues(new Float64Array([1, 2, 3, 4, 5]));
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Model Selection
|
|
264
|
-
|
|
265
|
-
```javascript
|
|
266
|
-
import { JsDataProfile, selectModels } from '@sipemu/anofox-forecast';
|
|
267
|
-
|
|
268
|
-
const profile = JsDataProfile.fromSeries(ts);
|
|
269
|
-
|
|
270
|
-
// Get model recommendations based on data characteristics
|
|
271
|
-
const result = selectModels(profile);
|
|
272
|
-
console.log('Recommended:', result.recommended); // ["ARIMA", "ETS", "Naive", "SES"]
|
|
273
|
-
console.log('Reasoning:', result.reasoning); // ["High autocorrelation...", ...]
|
|
274
|
-
|
|
275
|
-
// Filter to available models
|
|
276
|
-
const filtered = selectModels(profile, ["Naive", "SES", "ARIMA"]);
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### Pipeline Builder
|
|
280
|
-
|
|
281
|
-
```javascript
|
|
282
|
-
import { JsPipelineBuilder } from '@sipemu/anofox-forecast';
|
|
283
|
-
|
|
284
|
-
// Build and execute a forecasting pipeline
|
|
285
|
-
const result = new JsPipelineBuilder()
|
|
286
|
-
.profile() // enable data profiling
|
|
287
|
-
.preprocess('auto') // auto Box-Cox + outlier treatment
|
|
288
|
-
.metric('auto') // data-aware metric selection
|
|
289
|
-
.ensemble('auto') // ensemble if MCS includes > 1 model
|
|
290
|
-
.addModel('Naive')
|
|
291
|
-
.addModel('SES')
|
|
292
|
-
.addModel('SMA')
|
|
293
|
-
.withFallback() // Naive → SMA fallback chain
|
|
294
|
-
.nonNegative() // clamp forecasts >= 0
|
|
295
|
-
.execute(ts, 12); // 12-step forecast
|
|
296
|
-
|
|
297
|
-
console.log('Model:', result.modelName);
|
|
298
|
-
console.log('Forecast:', result.forecast.values);
|
|
299
|
-
console.log('Decision log:', result.decisionLog);
|
|
300
|
-
|
|
301
|
-
// Access diagnostics
|
|
302
|
-
const profile = result.profile; // JsDataProfile or undefined
|
|
303
|
-
const mcs = result.modelConfidenceSet; // { included, pValue, singleWinner }
|
|
304
|
-
const scores = result.metricScores; // [{ model, score, components }]
|
|
305
|
-
const weights = result.ensembleWeights; // [{ model, weight }] or undefined
|
|
306
|
-
const preprocess = result.preprocessInfo; // { boxcoxLambda, outliersReplaced, stepsApplied }
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
#### Builder Options
|
|
310
|
-
|
|
311
|
-
| Method | Options | Description |
|
|
312
|
-
|--------|---------|-------------|
|
|
313
|
-
| `profile()` | — | Enable data profiling |
|
|
314
|
-
| `preprocess(mode)` | `"auto"`, `"none"` | Preprocessing (Box-Cox, outlier replacement) |
|
|
315
|
-
| `metric(strategy)` | `"auto"`, `"mae"`, `"mse"`, `"rmse"`, `"smape"`, `"wape"`, `"mda"` | Metric for model ranking |
|
|
316
|
-
| `ensemble(mode)` | `"auto"`, `"none"`, `"mean"`, `"median"`, `"weighted"` | Ensemble construction |
|
|
317
|
-
| `addModel(name)` | `"Naive"`, `"SES"`, `"SMA"`, `"SMA3"`, `"SMA5"`, `"SMA10"`, `"SeasonalNaive"` | Register a model |
|
|
318
|
-
| `addSeasonalModel(name, period)` | — | Register a seasonal model |
|
|
319
|
-
| `selectModels(k)` | — | Select top-K models |
|
|
320
|
-
| `crossValidate(folds, horizon)` | — | Enable cross-validation |
|
|
321
|
-
| `withFallback()` | — | Enable fallback chain |
|
|
322
|
-
| `nonNegative()` | — | Clamp forecasts to non-negative |
|
|
323
|
-
| `seasonalPeriod(p)` | — | Set seasonal period hint |
|
|
324
|
-
|
|
325
|
-
### Pipeline Report
|
|
326
|
-
|
|
327
|
-
```javascript
|
|
328
|
-
// Generate a structured report
|
|
329
|
-
const report = result.report();
|
|
330
|
-
console.log(report.title); // "Pipeline Report: SES"
|
|
331
|
-
console.log(report.sectionCount); // number of sections
|
|
332
|
-
console.log(report.toString()); // full formatted text
|
|
333
|
-
|
|
334
|
-
// Report as JSON with typed sections
|
|
335
|
-
const json = report.toJSON();
|
|
336
|
-
// { title, sections: [{ heading, content: { type, ... } }] }
|
|
337
|
-
// Content types: "text", "keyValue" (with pairs), "table" (with headers + rows)
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### Explain Result
|
|
341
|
-
|
|
342
|
-
```javascript
|
|
343
|
-
import { explainResult } from '@sipemu/anofox-forecast';
|
|
344
|
-
|
|
345
|
-
// Generate a human-readable explanation
|
|
346
|
-
const brief = explainResult(result, 'brief');
|
|
347
|
-
console.log(brief.summary); // "Selected SES for 12-step forecast."
|
|
348
|
-
|
|
349
|
-
const detailed = explainResult(result, 'detailed');
|
|
350
|
-
console.log(detailed.summary);
|
|
351
|
-
detailed.sections.forEach(s => console.log(s.heading, s.content));
|
|
352
|
-
```
|
|
353
|
-
|
|
354
228
|
## Calendar Annotations
|
|
355
229
|
|
|
356
230
|
Add holidays and named regressors for models that support exogenous variables:
|
|
@@ -404,11 +278,23 @@ model.fit(ts);
|
|
|
404
278
|
const forecast = model.predict(10);
|
|
405
279
|
```
|
|
406
280
|
|
|
281
|
+
## What's New in the Rust Crate (v0.4.8)
|
|
282
|
+
|
|
283
|
+
These features are available in the Rust crate but not yet exposed as WASM bindings:
|
|
284
|
+
|
|
285
|
+
- **Per-horizon-step conformal prediction** — separate interval widths per forecast step
|
|
286
|
+
- **Bootstrap prediction intervals** — model-agnostic residual resampling with cumulative error paths
|
|
287
|
+
- **Calendar feature engineering** — cyclical sin/cos encoding, binary indicators (weekend, month-end, etc.)
|
|
288
|
+
- **Future timestamp generation** — calendar-aware (`generate_future_timestamps`)
|
|
289
|
+
- **Auto-lag selection** for RegressionForecaster (BIC/AIC)
|
|
290
|
+
- **Differencing** for RegressionForecaster (regular + seasonal)
|
|
291
|
+
- **Reworked cross-validation** — backward-anchored folds, n_folds-driven
|
|
292
|
+
|
|
407
293
|
## Limitations
|
|
408
294
|
|
|
409
295
|
- The `parallel` feature from the Rust crate is not available in WASM
|
|
410
296
|
- IDR (Isotonic Distributional Regression) and QRA are not yet exposed in WASM
|
|
411
|
-
-
|
|
297
|
+
- Per-step conformal, bootstrap predictor, and calendar features are Rust-only (not yet in WASM)
|
|
412
298
|
|
|
413
299
|
## License
|
|
414
300
|
|