@sipemu/anofox-forecast 0.4.0 → 0.4.2
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 +31 -0
- package/anofox_forecast_js.d.ts +84 -20
- package/anofox_forecast_js.js +138 -0
- package/anofox_forecast_js_bg.wasm +0 -0
- package/anofox_forecast_js_bg.wasm.d.ts +26 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,37 @@ For `ETSForecaster`, use string codes:
|
|
|
160
160
|
const ets = new ETSForecaster("A", "A", "M", 12);
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
+
#### Standard ETS Notation
|
|
164
|
+
|
|
165
|
+
You can also use standard ETS notation (following [FPP3 taxonomy](https://otexts.com/fpp3/taxonomy.html)):
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
// Create from notation string
|
|
169
|
+
const model = ETSForecaster.fromNotation("AAA", 12); // Holt-Winters additive
|
|
170
|
+
const model = ETSForecaster.fromNotation("MAM", 12); // Multiplicative Holt-Winters
|
|
171
|
+
const model = ETSForecaster.fromNotation("AAdM", 12); // Damped trend, multiplicative seasonal
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Valid notation format: `ErrorTrendSeasonal`
|
|
175
|
+
- First letter: Error (A or M)
|
|
176
|
+
- Second letter(s): Trend (N, A, or Ad)
|
|
177
|
+
- Third letter: Seasonal (N, A, or M)
|
|
178
|
+
|
|
179
|
+
#### Model Validation
|
|
180
|
+
|
|
181
|
+
Some ETS combinations are unstable and will throw an error:
|
|
182
|
+
- `MAA` - Multiplicative error + Additive trend + Additive seasonal
|
|
183
|
+
- `MAdA` - Multiplicative error + Damped trend + Additive seasonal
|
|
184
|
+
|
|
185
|
+
You can check validity before creating:
|
|
186
|
+
|
|
187
|
+
```javascript
|
|
188
|
+
// Check if a specification is valid
|
|
189
|
+
ETSForecaster.isValidSpec("A", "A", "A"); // true
|
|
190
|
+
ETSForecaster.isValidSpec("M", "A", "M"); // true
|
|
191
|
+
ETSForecaster.isValidSpec("M", "A", "A"); // false (unstable)
|
|
192
|
+
```
|
|
193
|
+
|
|
163
194
|
## Browser Usage
|
|
164
195
|
|
|
165
196
|
```html
|
package/anofox_forecast_js.d.ts
CHANGED
|
@@ -38,6 +38,23 @@ export class AutoARIMAForecaster {
|
|
|
38
38
|
export class AutoETSForecaster {
|
|
39
39
|
free(): void;
|
|
40
40
|
[Symbol.dispose](): void;
|
|
41
|
+
/**
|
|
42
|
+
* Create AutoETS with custom configuration.
|
|
43
|
+
* @param period - Optional seasonal period (null for auto-detection)
|
|
44
|
+
* @param allow_multiplicative_error - Allow multiplicative error models
|
|
45
|
+
* @param allow_multiplicative_seasonal - Allow multiplicative seasonality
|
|
46
|
+
* @param allow_damped - Allow damped trend models
|
|
47
|
+
*/
|
|
48
|
+
static withConfig(period: number | null | undefined, allow_multiplicative_error: boolean, allow_multiplicative_seasonal: boolean, allow_damped: boolean): AutoETSForecaster;
|
|
49
|
+
/**
|
|
50
|
+
* Create AutoETS with a specific seasonal period.
|
|
51
|
+
*/
|
|
52
|
+
static withPeriod(period: number): AutoETSForecaster;
|
|
53
|
+
/**
|
|
54
|
+
* Create AutoETS restricted to additive models only.
|
|
55
|
+
* This excludes multiplicative error and multiplicative seasonality.
|
|
56
|
+
*/
|
|
57
|
+
static additiveOnly(): AutoETSForecaster;
|
|
41
58
|
fit(series: TimeSeries): void;
|
|
42
59
|
constructor();
|
|
43
60
|
predict(horizon: number): Forecast;
|
|
@@ -100,6 +117,40 @@ export class DynamicThetaForecaster {
|
|
|
100
117
|
export class ETSForecaster {
|
|
101
118
|
free(): void;
|
|
102
119
|
[Symbol.dispose](): void;
|
|
120
|
+
/**
|
|
121
|
+
* Create an ETS model from standard notation.
|
|
122
|
+
*
|
|
123
|
+
* @param notation - ETS notation string like "ANN", "AAA", "MAM", "AAdM"
|
|
124
|
+
* @param period - Seasonal period (required if notation has seasonal component)
|
|
125
|
+
*
|
|
126
|
+
* Format: ErrorTrendSeasonal
|
|
127
|
+
* - Error: A (additive) or M (multiplicative)
|
|
128
|
+
* - Trend: N (none), A (additive), or Ad (additive damped)
|
|
129
|
+
* - Seasonal: N (none), A (additive), or M (multiplicative)
|
|
130
|
+
*
|
|
131
|
+
* Examples:
|
|
132
|
+
* - "ANN" - Simple exponential smoothing
|
|
133
|
+
* - "AAN" - Holt's linear method
|
|
134
|
+
* - "AAA" - Holt-Winters additive
|
|
135
|
+
* - "MAM" - Multiplicative Holt-Winters
|
|
136
|
+
* - "AAdM" - Damped trend with multiplicative seasonal
|
|
137
|
+
*
|
|
138
|
+
* @throws Error for invalid notation or unstable combinations (MAA, MAdA)
|
|
139
|
+
*/
|
|
140
|
+
static fromNotation(notation: string, period: number): ETSForecaster;
|
|
141
|
+
/**
|
|
142
|
+
* Check if an ETS specification is valid/stable.
|
|
143
|
+
*
|
|
144
|
+
* @param error - Error type: "A" or "M"
|
|
145
|
+
* @param trend - Trend type: "N", "A", or "Ad"
|
|
146
|
+
* @param seasonal - Seasonal type: "N", "A", or "M"
|
|
147
|
+
* @returns true if the combination is stable and usable
|
|
148
|
+
*
|
|
149
|
+
* Invalid combinations (return false):
|
|
150
|
+
* - M,A,A - Multiplicative error with additive trend and additive seasonal
|
|
151
|
+
* - M,Ad,A - Multiplicative error with damped trend and additive seasonal
|
|
152
|
+
*/
|
|
153
|
+
static isValidSpec(error: string, trend: string, seasonal: string): boolean;
|
|
103
154
|
fit(series: TimeSeries): void;
|
|
104
155
|
/**
|
|
105
156
|
* Create an ETS model with specified components.
|
|
@@ -107,6 +158,7 @@ export class ETSForecaster {
|
|
|
107
158
|
* @param trend - Trend type: "N" (none), "A" (additive), or "Ad" (additive damped)
|
|
108
159
|
* @param seasonal - Seasonal type: "N" (none), "A" (additive), or "M" (multiplicative)
|
|
109
160
|
* @param period - Seasonal period (ignored if seasonal is "N")
|
|
161
|
+
* @throws Error if the combination is unstable (MAA or MAdA)
|
|
110
162
|
*/
|
|
111
163
|
constructor(error: string, trend: string, seasonal: string, period: number);
|
|
112
164
|
predict(horizon: number): Forecast;
|
|
@@ -189,6 +241,12 @@ export class HoltWintersForecaster {
|
|
|
189
241
|
* @param period - Seasonal period
|
|
190
242
|
*/
|
|
191
243
|
constructor(alpha: number, beta: number, gamma: number, period: number);
|
|
244
|
+
/**
|
|
245
|
+
* Create with automatic parameter optimization.
|
|
246
|
+
* @param period - Seasonal period
|
|
247
|
+
* @param seasonal_type - "additive" or "multiplicative"
|
|
248
|
+
*/
|
|
249
|
+
static auto(period: number, seasonal_type: string): HoltWintersForecaster;
|
|
192
250
|
predict(horizon: number): Forecast;
|
|
193
251
|
readonly name: string;
|
|
194
252
|
}
|
|
@@ -459,6 +517,7 @@ export interface InitOutput {
|
|
|
459
517
|
readonly __wbg_crostonforecaster_free: (a: number, b: number) => void;
|
|
460
518
|
readonly __wbg_dynamicthetaforecaster_free: (a: number, b: number) => void;
|
|
461
519
|
readonly __wbg_etsforecaster_free: (a: number, b: number) => void;
|
|
520
|
+
readonly __wbg_forecast_free: (a: number, b: number) => void;
|
|
462
521
|
readonly __wbg_garchforecaster_free: (a: number, b: number) => void;
|
|
463
522
|
readonly __wbg_holtforecaster_free: (a: number, b: number) => void;
|
|
464
523
|
readonly __wbg_holtwintersforecaster_free: (a: number, b: number) => void;
|
|
@@ -477,8 +536,7 @@ export interface InitOutput {
|
|
|
477
536
|
readonly __wbg_smaforecaster_free: (a: number, b: number) => void;
|
|
478
537
|
readonly __wbg_tbatsforecaster_free: (a: number, b: number) => void;
|
|
479
538
|
readonly __wbg_thetaforecaster_free: (a: number, b: number) => void;
|
|
480
|
-
readonly
|
|
481
|
-
readonly __wbg_windowaverageforecaster_free: (a: number, b: number) => void;
|
|
539
|
+
readonly __wbg_timeseries_free: (a: number, b: number) => void;
|
|
482
540
|
readonly adidaforecaster_fit: (a: number, b: number) => [number, number];
|
|
483
541
|
readonly adidaforecaster_name: (a: number) => [number, number];
|
|
484
542
|
readonly adidaforecaster_new: () => number;
|
|
@@ -493,10 +551,13 @@ export interface InitOutput {
|
|
|
493
551
|
readonly autoarimaforecaster_new: () => number;
|
|
494
552
|
readonly autoarimaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
495
553
|
readonly autoarimaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
554
|
+
readonly autoetsforecaster_additiveOnly: () => number;
|
|
496
555
|
readonly autoetsforecaster_fit: (a: number, b: number) => [number, number];
|
|
497
556
|
readonly autoetsforecaster_name: (a: number) => [number, number];
|
|
498
557
|
readonly autoetsforecaster_new: () => number;
|
|
499
558
|
readonly autoetsforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
559
|
+
readonly autoetsforecaster_withConfig: (a: number, b: number, c: number, d: number) => number;
|
|
560
|
+
readonly autoetsforecaster_withPeriod: (a: number) => number;
|
|
500
561
|
readonly autotbatsforecaster_fit: (a: number, b: number) => [number, number];
|
|
501
562
|
readonly autotbatsforecaster_name: (a: number) => [number, number];
|
|
502
563
|
readonly autotbatsforecaster_new: (a: number, b: number) => number;
|
|
@@ -518,9 +579,17 @@ export interface InitOutput {
|
|
|
518
579
|
readonly dynamicthetaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
519
580
|
readonly dynamicthetaforecaster_seasonal: (a: number) => number;
|
|
520
581
|
readonly etsforecaster_fit: (a: number, b: number) => [number, number];
|
|
582
|
+
readonly etsforecaster_fromNotation: (a: number, b: number, c: number) => [number, number, number];
|
|
583
|
+
readonly etsforecaster_isValidSpec: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
521
584
|
readonly etsforecaster_name: (a: number) => [number, number];
|
|
522
585
|
readonly etsforecaster_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
523
586
|
readonly etsforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
587
|
+
readonly forecast_hasLower: (a: number) => number;
|
|
588
|
+
readonly forecast_hasUpper: (a: number) => number;
|
|
589
|
+
readonly forecast_horizon: (a: number) => number;
|
|
590
|
+
readonly forecast_lower: (a: number) => [number, number];
|
|
591
|
+
readonly forecast_upper: (a: number) => [number, number];
|
|
592
|
+
readonly forecast_values: (a: number) => [number, number];
|
|
524
593
|
readonly garchforecaster_fit: (a: number, b: number) => [number, number];
|
|
525
594
|
readonly garchforecaster_name: (a: number) => [number, number];
|
|
526
595
|
readonly garchforecaster_new: (a: number, b: number) => number;
|
|
@@ -529,6 +598,7 @@ export interface InitOutput {
|
|
|
529
598
|
readonly holtforecaster_name: (a: number) => [number, number];
|
|
530
599
|
readonly holtforecaster_new: (a: number, b: number) => number;
|
|
531
600
|
readonly holtforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
601
|
+
readonly holtwintersforecaster_auto: (a: number, b: number, c: number) => [number, number, number];
|
|
532
602
|
readonly holtwintersforecaster_fit: (a: number, b: number) => [number, number];
|
|
533
603
|
readonly holtwintersforecaster_multiplicative: (a: number, b: number, c: number, d: number) => number;
|
|
534
604
|
readonly holtwintersforecaster_name: (a: number) => [number, number];
|
|
@@ -538,6 +608,7 @@ export interface InitOutput {
|
|
|
538
608
|
readonly imapaforecaster_name: (a: number) => [number, number];
|
|
539
609
|
readonly imapaforecaster_new: () => number;
|
|
540
610
|
readonly imapaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
611
|
+
readonly init: () => void;
|
|
541
612
|
readonly meanforecaster_fit: (a: number, b: number) => [number, number];
|
|
542
613
|
readonly meanforecaster_name: (a: number) => [number, number];
|
|
543
614
|
readonly meanforecaster_new: () => number;
|
|
@@ -601,35 +672,28 @@ export interface InitOutput {
|
|
|
601
672
|
readonly thetaforecaster_new: () => number;
|
|
602
673
|
readonly thetaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
603
674
|
readonly thetaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
675
|
+
readonly timeseries_hasMissingValues: (a: number) => number;
|
|
676
|
+
readonly timeseries_isEmpty: (a: number) => number;
|
|
677
|
+
readonly timeseries_length: (a: number) => number;
|
|
678
|
+
readonly timeseries_new: (a: number, b: number) => [number, number, number];
|
|
679
|
+
readonly timeseries_slice: (a: number, b: number, c: number) => [number, number, number];
|
|
680
|
+
readonly timeseries_values: (a: number) => [number, number];
|
|
681
|
+
readonly timeseries_withTimestamps: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
604
682
|
readonly tsbforecaster_fit: (a: number, b: number) => [number, number];
|
|
605
683
|
readonly tsbforecaster_name: (a: number) => [number, number];
|
|
606
684
|
readonly tsbforecaster_new: () => number;
|
|
607
685
|
readonly tsbforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
686
|
+
readonly version: () => [number, number];
|
|
608
687
|
readonly windowaverageforecaster_fit: (a: number, b: number) => [number, number];
|
|
609
688
|
readonly windowaverageforecaster_name: (a: number) => [number, number];
|
|
610
689
|
readonly windowaverageforecaster_new: (a: number) => number;
|
|
611
690
|
readonly windowaverageforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
612
|
-
readonly
|
|
613
|
-
readonly
|
|
614
|
-
readonly __wbg_forecast_free: (a: number, b: number) => void;
|
|
615
|
-
readonly __wbg_timeseries_free: (a: number, b: number) => void;
|
|
616
|
-
readonly forecast_hasLower: (a: number) => number;
|
|
617
|
-
readonly forecast_hasUpper: (a: number) => number;
|
|
618
|
-
readonly forecast_horizon: (a: number) => number;
|
|
619
|
-
readonly forecast_lower: (a: number) => [number, number];
|
|
620
|
-
readonly forecast_upper: (a: number) => [number, number];
|
|
621
|
-
readonly forecast_values: (a: number) => [number, number];
|
|
622
|
-
readonly timeseries_hasMissingValues: (a: number) => number;
|
|
623
|
-
readonly timeseries_isEmpty: (a: number) => number;
|
|
624
|
-
readonly timeseries_length: (a: number) => number;
|
|
625
|
-
readonly timeseries_new: (a: number, b: number) => [number, number, number];
|
|
626
|
-
readonly timeseries_slice: (a: number, b: number, c: number) => [number, number, number];
|
|
627
|
-
readonly timeseries_values: (a: number) => [number, number];
|
|
628
|
-
readonly timeseries_withTimestamps: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
691
|
+
readonly __wbg_tsbforecaster_free: (a: number, b: number) => void;
|
|
692
|
+
readonly __wbg_windowaverageforecaster_free: (a: number, b: number) => void;
|
|
629
693
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
630
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
631
694
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
632
695
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
696
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
633
697
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
634
698
|
readonly __wbindgen_start: () => void;
|
|
635
699
|
}
|
package/anofox_forecast_js.js
CHANGED
|
@@ -40,6 +40,10 @@ function getUint8ArrayMemory0() {
|
|
|
40
40
|
return cachedUint8ArrayMemory0;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function isLikeNone(x) {
|
|
44
|
+
return x === undefined || x === null;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
function passArray32ToWasm0(arg, malloc) {
|
|
44
48
|
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
45
49
|
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
@@ -461,8 +465,17 @@ if (Symbol.dispose) AutoARIMAForecaster.prototype[Symbol.dispose] = AutoARIMAFor
|
|
|
461
465
|
|
|
462
466
|
/**
|
|
463
467
|
* AutoETS - Automatic ETS model selection.
|
|
468
|
+
*
|
|
469
|
+
* Follows the ETS taxonomy from FPP3: <https://otexts.com/fpp3/taxonomy.html>
|
|
464
470
|
*/
|
|
465
471
|
export class AutoETSForecaster {
|
|
472
|
+
static __wrap(ptr) {
|
|
473
|
+
ptr = ptr >>> 0;
|
|
474
|
+
const obj = Object.create(AutoETSForecaster.prototype);
|
|
475
|
+
obj.__wbg_ptr = ptr;
|
|
476
|
+
AutoETSForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
477
|
+
return obj;
|
|
478
|
+
}
|
|
466
479
|
__destroy_into_raw() {
|
|
467
480
|
const ptr = this.__wbg_ptr;
|
|
468
481
|
this.__wbg_ptr = 0;
|
|
@@ -473,6 +486,40 @@ export class AutoETSForecaster {
|
|
|
473
486
|
const ptr = this.__destroy_into_raw();
|
|
474
487
|
wasm.__wbg_autoetsforecaster_free(ptr, 0);
|
|
475
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Create AutoETS with custom configuration.
|
|
491
|
+
* @param period - Optional seasonal period (null for auto-detection)
|
|
492
|
+
* @param allow_multiplicative_error - Allow multiplicative error models
|
|
493
|
+
* @param allow_multiplicative_seasonal - Allow multiplicative seasonality
|
|
494
|
+
* @param allow_damped - Allow damped trend models
|
|
495
|
+
* @param {number | null | undefined} period
|
|
496
|
+
* @param {boolean} allow_multiplicative_error
|
|
497
|
+
* @param {boolean} allow_multiplicative_seasonal
|
|
498
|
+
* @param {boolean} allow_damped
|
|
499
|
+
* @returns {AutoETSForecaster}
|
|
500
|
+
*/
|
|
501
|
+
static withConfig(period, allow_multiplicative_error, allow_multiplicative_seasonal, allow_damped) {
|
|
502
|
+
const ret = wasm.autoetsforecaster_withConfig(isLikeNone(period) ? 0x100000001 : (period) >>> 0, allow_multiplicative_error, allow_multiplicative_seasonal, allow_damped);
|
|
503
|
+
return AutoETSForecaster.__wrap(ret);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Create AutoETS with a specific seasonal period.
|
|
507
|
+
* @param {number} period
|
|
508
|
+
* @returns {AutoETSForecaster}
|
|
509
|
+
*/
|
|
510
|
+
static withPeriod(period) {
|
|
511
|
+
const ret = wasm.autoetsforecaster_withPeriod(period);
|
|
512
|
+
return AutoETSForecaster.__wrap(ret);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Create AutoETS restricted to additive models only.
|
|
516
|
+
* This excludes multiplicative error and multiplicative seasonality.
|
|
517
|
+
* @returns {AutoETSForecaster}
|
|
518
|
+
*/
|
|
519
|
+
static additiveOnly() {
|
|
520
|
+
const ret = wasm.autoetsforecaster_additiveOnly();
|
|
521
|
+
return AutoETSForecaster.__wrap(ret);
|
|
522
|
+
}
|
|
476
523
|
/**
|
|
477
524
|
* @param {TimeSeries} series
|
|
478
525
|
*/
|
|
@@ -815,9 +862,24 @@ if (Symbol.dispose) DynamicThetaForecaster.prototype[Symbol.dispose] = DynamicTh
|
|
|
815
862
|
|
|
816
863
|
/**
|
|
817
864
|
* ETS (Error-Trend-Seasonal) state-space model.
|
|
865
|
+
*
|
|
818
866
|
* Use string codes: "A" = Additive, "M" = Multiplicative, "N" = None
|
|
867
|
+
* Or use standard ETS notation like "ANN", "AAA", "MAM", "AAdM".
|
|
868
|
+
*
|
|
869
|
+
* Follows the ETS taxonomy from FPP3: <https://otexts.com/fpp3/taxonomy.html>
|
|
870
|
+
*
|
|
871
|
+
* Note: Some combinations are invalid/unstable per FPP3:
|
|
872
|
+
* - MAA (Multiplicative error + Additive trend + Additive seasonal)
|
|
873
|
+
* - MAdA (Multiplicative error + Damped trend + Additive seasonal)
|
|
819
874
|
*/
|
|
820
875
|
export class ETSForecaster {
|
|
876
|
+
static __wrap(ptr) {
|
|
877
|
+
ptr = ptr >>> 0;
|
|
878
|
+
const obj = Object.create(ETSForecaster.prototype);
|
|
879
|
+
obj.__wbg_ptr = ptr;
|
|
880
|
+
ETSForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
881
|
+
return obj;
|
|
882
|
+
}
|
|
821
883
|
__destroy_into_raw() {
|
|
822
884
|
const ptr = this.__wbg_ptr;
|
|
823
885
|
this.__wbg_ptr = 0;
|
|
@@ -828,6 +890,64 @@ export class ETSForecaster {
|
|
|
828
890
|
const ptr = this.__destroy_into_raw();
|
|
829
891
|
wasm.__wbg_etsforecaster_free(ptr, 0);
|
|
830
892
|
}
|
|
893
|
+
/**
|
|
894
|
+
* Create an ETS model from standard notation.
|
|
895
|
+
*
|
|
896
|
+
* @param notation - ETS notation string like "ANN", "AAA", "MAM", "AAdM"
|
|
897
|
+
* @param period - Seasonal period (required if notation has seasonal component)
|
|
898
|
+
*
|
|
899
|
+
* Format: ErrorTrendSeasonal
|
|
900
|
+
* - Error: A (additive) or M (multiplicative)
|
|
901
|
+
* - Trend: N (none), A (additive), or Ad (additive damped)
|
|
902
|
+
* - Seasonal: N (none), A (additive), or M (multiplicative)
|
|
903
|
+
*
|
|
904
|
+
* Examples:
|
|
905
|
+
* - "ANN" - Simple exponential smoothing
|
|
906
|
+
* - "AAN" - Holt's linear method
|
|
907
|
+
* - "AAA" - Holt-Winters additive
|
|
908
|
+
* - "MAM" - Multiplicative Holt-Winters
|
|
909
|
+
* - "AAdM" - Damped trend with multiplicative seasonal
|
|
910
|
+
*
|
|
911
|
+
* @throws Error for invalid notation or unstable combinations (MAA, MAdA)
|
|
912
|
+
* @param {string} notation
|
|
913
|
+
* @param {number} period
|
|
914
|
+
* @returns {ETSForecaster}
|
|
915
|
+
*/
|
|
916
|
+
static fromNotation(notation, period) {
|
|
917
|
+
const ptr0 = passStringToWasm0(notation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
918
|
+
const len0 = WASM_VECTOR_LEN;
|
|
919
|
+
const ret = wasm.etsforecaster_fromNotation(ptr0, len0, period);
|
|
920
|
+
if (ret[2]) {
|
|
921
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
922
|
+
}
|
|
923
|
+
return ETSForecaster.__wrap(ret[0]);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Check if an ETS specification is valid/stable.
|
|
927
|
+
*
|
|
928
|
+
* @param error - Error type: "A" or "M"
|
|
929
|
+
* @param trend - Trend type: "N", "A", or "Ad"
|
|
930
|
+
* @param seasonal - Seasonal type: "N", "A", or "M"
|
|
931
|
+
* @returns true if the combination is stable and usable
|
|
932
|
+
*
|
|
933
|
+
* Invalid combinations (return false):
|
|
934
|
+
* - M,A,A - Multiplicative error with additive trend and additive seasonal
|
|
935
|
+
* - M,Ad,A - Multiplicative error with damped trend and additive seasonal
|
|
936
|
+
* @param {string} error
|
|
937
|
+
* @param {string} trend
|
|
938
|
+
* @param {string} seasonal
|
|
939
|
+
* @returns {boolean}
|
|
940
|
+
*/
|
|
941
|
+
static isValidSpec(error, trend, seasonal) {
|
|
942
|
+
const ptr0 = passStringToWasm0(error, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
943
|
+
const len0 = WASM_VECTOR_LEN;
|
|
944
|
+
const ptr1 = passStringToWasm0(trend, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
945
|
+
const len1 = WASM_VECTOR_LEN;
|
|
946
|
+
const ptr2 = passStringToWasm0(seasonal, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
947
|
+
const len2 = WASM_VECTOR_LEN;
|
|
948
|
+
const ret = wasm.etsforecaster_isValidSpec(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
949
|
+
return ret !== 0;
|
|
950
|
+
}
|
|
831
951
|
/**
|
|
832
952
|
* @param {TimeSeries} series
|
|
833
953
|
*/
|
|
@@ -844,6 +964,7 @@ export class ETSForecaster {
|
|
|
844
964
|
* @param trend - Trend type: "N" (none), "A" (additive), or "Ad" (additive damped)
|
|
845
965
|
* @param seasonal - Seasonal type: "N" (none), "A" (additive), or "M" (multiplicative)
|
|
846
966
|
* @param period - Seasonal period (ignored if seasonal is "N")
|
|
967
|
+
* @throws Error if the combination is unstable (MAA or MAdA)
|
|
847
968
|
* @param {string} error
|
|
848
969
|
* @param {string} trend
|
|
849
970
|
* @param {string} seasonal
|
|
@@ -1173,6 +1294,23 @@ export class HoltWintersForecaster {
|
|
|
1173
1294
|
HoltWintersForecasterFinalization.register(this, this.__wbg_ptr, this);
|
|
1174
1295
|
return this;
|
|
1175
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Create with automatic parameter optimization.
|
|
1299
|
+
* @param period - Seasonal period
|
|
1300
|
+
* @param seasonal_type - "additive" or "multiplicative"
|
|
1301
|
+
* @param {number} period
|
|
1302
|
+
* @param {string} seasonal_type
|
|
1303
|
+
* @returns {HoltWintersForecaster}
|
|
1304
|
+
*/
|
|
1305
|
+
static auto(period, seasonal_type) {
|
|
1306
|
+
const ptr0 = passStringToWasm0(seasonal_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1308
|
+
const ret = wasm.holtwintersforecaster_auto(period, ptr0, len0);
|
|
1309
|
+
if (ret[2]) {
|
|
1310
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1311
|
+
}
|
|
1312
|
+
return HoltWintersForecaster.__wrap(ret[0]);
|
|
1313
|
+
}
|
|
1176
1314
|
/**
|
|
1177
1315
|
* @returns {string}
|
|
1178
1316
|
*/
|
|
Binary file
|
|
@@ -10,6 +10,7 @@ export const __wbg_autothetaforecaster_free: (a: number, b: number) => void;
|
|
|
10
10
|
export const __wbg_crostonforecaster_free: (a: number, b: number) => void;
|
|
11
11
|
export const __wbg_dynamicthetaforecaster_free: (a: number, b: number) => void;
|
|
12
12
|
export const __wbg_etsforecaster_free: (a: number, b: number) => void;
|
|
13
|
+
export const __wbg_forecast_free: (a: number, b: number) => void;
|
|
13
14
|
export const __wbg_garchforecaster_free: (a: number, b: number) => void;
|
|
14
15
|
export const __wbg_holtforecaster_free: (a: number, b: number) => void;
|
|
15
16
|
export const __wbg_holtwintersforecaster_free: (a: number, b: number) => void;
|
|
@@ -28,8 +29,7 @@ export const __wbg_sesforecaster_free: (a: number, b: number) => void;
|
|
|
28
29
|
export const __wbg_smaforecaster_free: (a: number, b: number) => void;
|
|
29
30
|
export const __wbg_tbatsforecaster_free: (a: number, b: number) => void;
|
|
30
31
|
export const __wbg_thetaforecaster_free: (a: number, b: number) => void;
|
|
31
|
-
export const
|
|
32
|
-
export const __wbg_windowaverageforecaster_free: (a: number, b: number) => void;
|
|
32
|
+
export const __wbg_timeseries_free: (a: number, b: number) => void;
|
|
33
33
|
export const adidaforecaster_fit: (a: number, b: number) => [number, number];
|
|
34
34
|
export const adidaforecaster_name: (a: number) => [number, number];
|
|
35
35
|
export const adidaforecaster_new: () => number;
|
|
@@ -44,10 +44,13 @@ export const autoarimaforecaster_name: (a: number) => [number, number];
|
|
|
44
44
|
export const autoarimaforecaster_new: () => number;
|
|
45
45
|
export const autoarimaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
46
46
|
export const autoarimaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
47
|
+
export const autoetsforecaster_additiveOnly: () => number;
|
|
47
48
|
export const autoetsforecaster_fit: (a: number, b: number) => [number, number];
|
|
48
49
|
export const autoetsforecaster_name: (a: number) => [number, number];
|
|
49
50
|
export const autoetsforecaster_new: () => number;
|
|
50
51
|
export const autoetsforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
52
|
+
export const autoetsforecaster_withConfig: (a: number, b: number, c: number, d: number) => number;
|
|
53
|
+
export const autoetsforecaster_withPeriod: (a: number) => number;
|
|
51
54
|
export const autotbatsforecaster_fit: (a: number, b: number) => [number, number];
|
|
52
55
|
export const autotbatsforecaster_name: (a: number) => [number, number];
|
|
53
56
|
export const autotbatsforecaster_new: (a: number, b: number) => number;
|
|
@@ -69,9 +72,17 @@ export const dynamicthetaforecaster_predict: (a: number, b: number) => [number,
|
|
|
69
72
|
export const dynamicthetaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
70
73
|
export const dynamicthetaforecaster_seasonal: (a: number) => number;
|
|
71
74
|
export const etsforecaster_fit: (a: number, b: number) => [number, number];
|
|
75
|
+
export const etsforecaster_fromNotation: (a: number, b: number, c: number) => [number, number, number];
|
|
76
|
+
export const etsforecaster_isValidSpec: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
72
77
|
export const etsforecaster_name: (a: number) => [number, number];
|
|
73
78
|
export const etsforecaster_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
74
79
|
export const etsforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
80
|
+
export const forecast_hasLower: (a: number) => number;
|
|
81
|
+
export const forecast_hasUpper: (a: number) => number;
|
|
82
|
+
export const forecast_horizon: (a: number) => number;
|
|
83
|
+
export const forecast_lower: (a: number) => [number, number];
|
|
84
|
+
export const forecast_upper: (a: number) => [number, number];
|
|
85
|
+
export const forecast_values: (a: number) => [number, number];
|
|
75
86
|
export const garchforecaster_fit: (a: number, b: number) => [number, number];
|
|
76
87
|
export const garchforecaster_name: (a: number) => [number, number];
|
|
77
88
|
export const garchforecaster_new: (a: number, b: number) => number;
|
|
@@ -80,6 +91,7 @@ export const holtforecaster_fit: (a: number, b: number) => [number, number];
|
|
|
80
91
|
export const holtforecaster_name: (a: number) => [number, number];
|
|
81
92
|
export const holtforecaster_new: (a: number, b: number) => number;
|
|
82
93
|
export const holtforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
94
|
+
export const holtwintersforecaster_auto: (a: number, b: number, c: number) => [number, number, number];
|
|
83
95
|
export const holtwintersforecaster_fit: (a: number, b: number) => [number, number];
|
|
84
96
|
export const holtwintersforecaster_multiplicative: (a: number, b: number, c: number, d: number) => number;
|
|
85
97
|
export const holtwintersforecaster_name: (a: number) => [number, number];
|
|
@@ -89,6 +101,7 @@ export const imapaforecaster_fit: (a: number, b: number) => [number, number];
|
|
|
89
101
|
export const imapaforecaster_name: (a: number) => [number, number];
|
|
90
102
|
export const imapaforecaster_new: () => number;
|
|
91
103
|
export const imapaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
104
|
+
export const init: () => void;
|
|
92
105
|
export const meanforecaster_fit: (a: number, b: number) => [number, number];
|
|
93
106
|
export const meanforecaster_name: (a: number) => [number, number];
|
|
94
107
|
export const meanforecaster_new: () => number;
|
|
@@ -152,34 +165,27 @@ export const thetaforecaster_name: (a: number) => [number, number];
|
|
|
152
165
|
export const thetaforecaster_new: () => number;
|
|
153
166
|
export const thetaforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
154
167
|
export const thetaforecaster_predictWithIntervals: (a: number, b: number, c: number) => [number, number, number];
|
|
168
|
+
export const timeseries_hasMissingValues: (a: number) => number;
|
|
169
|
+
export const timeseries_isEmpty: (a: number) => number;
|
|
170
|
+
export const timeseries_length: (a: number) => number;
|
|
171
|
+
export const timeseries_new: (a: number, b: number) => [number, number, number];
|
|
172
|
+
export const timeseries_slice: (a: number, b: number, c: number) => [number, number, number];
|
|
173
|
+
export const timeseries_values: (a: number) => [number, number];
|
|
174
|
+
export const timeseries_withTimestamps: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
155
175
|
export const tsbforecaster_fit: (a: number, b: number) => [number, number];
|
|
156
176
|
export const tsbforecaster_name: (a: number) => [number, number];
|
|
157
177
|
export const tsbforecaster_new: () => number;
|
|
158
178
|
export const tsbforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
179
|
+
export const version: () => [number, number];
|
|
159
180
|
export const windowaverageforecaster_fit: (a: number, b: number) => [number, number];
|
|
160
181
|
export const windowaverageforecaster_name: (a: number) => [number, number];
|
|
161
182
|
export const windowaverageforecaster_new: (a: number) => number;
|
|
162
183
|
export const windowaverageforecaster_predict: (a: number, b: number) => [number, number, number];
|
|
163
|
-
export const
|
|
164
|
-
export const
|
|
165
|
-
export const __wbg_forecast_free: (a: number, b: number) => void;
|
|
166
|
-
export const __wbg_timeseries_free: (a: number, b: number) => void;
|
|
167
|
-
export const forecast_hasLower: (a: number) => number;
|
|
168
|
-
export const forecast_hasUpper: (a: number) => number;
|
|
169
|
-
export const forecast_horizon: (a: number) => number;
|
|
170
|
-
export const forecast_lower: (a: number) => [number, number];
|
|
171
|
-
export const forecast_upper: (a: number) => [number, number];
|
|
172
|
-
export const forecast_values: (a: number) => [number, number];
|
|
173
|
-
export const timeseries_hasMissingValues: (a: number) => number;
|
|
174
|
-
export const timeseries_isEmpty: (a: number) => number;
|
|
175
|
-
export const timeseries_length: (a: number) => number;
|
|
176
|
-
export const timeseries_new: (a: number, b: number) => [number, number, number];
|
|
177
|
-
export const timeseries_slice: (a: number, b: number, c: number) => [number, number, number];
|
|
178
|
-
export const timeseries_values: (a: number) => [number, number];
|
|
179
|
-
export const timeseries_withTimestamps: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
184
|
+
export const __wbg_tsbforecaster_free: (a: number, b: number) => void;
|
|
185
|
+
export const __wbg_windowaverageforecaster_free: (a: number, b: number) => void;
|
|
180
186
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
181
|
-
export const __externref_table_dealloc: (a: number) => void;
|
|
182
187
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
183
188
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
189
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
184
190
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
185
191
|
export const __wbindgen_start: () => void;
|