@sipemu/anofox-forecast 0.4.5 → 0.4.6

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.
@@ -188,6 +188,10 @@ const AutoEnsembleForecasterFinalization = (typeof FinalizationRegistry === 'und
188
188
  ? { register: () => {}, unregister: () => {} }
189
189
  : new FinalizationRegistry(ptr => wasm.__wbg_autoensembleforecaster_free(ptr >>> 0, 1));
190
190
 
191
+ const AutoForecastBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
192
+ ? { register: () => {}, unregister: () => {} }
193
+ : new FinalizationRegistry(ptr => wasm.__wbg_autoforecastbuilder_free(ptr >>> 0, 1));
194
+
191
195
  const AutoForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
192
196
  ? { register: () => {}, unregister: () => {} }
193
197
  : new FinalizationRegistry(ptr => wasm.__wbg_autoforecaster_free(ptr >>> 0, 1));
@@ -256,6 +260,10 @@ const JsConformalResultFinalization = (typeof FinalizationRegistry === 'undefine
256
260
  ? { register: () => {}, unregister: () => {} }
257
261
  : new FinalizationRegistry(ptr => wasm.__wbg_jsconformalresult_free(ptr >>> 0, 1));
258
262
 
263
+ const JsDataProfileFinalization = (typeof FinalizationRegistry === 'undefined')
264
+ ? { register: () => {}, unregister: () => {} }
265
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsdataprofile_free(ptr >>> 0, 1));
266
+
259
267
  const JsHistoricalSimResultFinalization = (typeof FinalizationRegistry === 'undefined')
260
268
  ? { register: () => {}, unregister: () => {} }
261
269
  : new FinalizationRegistry(ptr => wasm.__wbg_jshistoricalsimresult_free(ptr >>> 0, 1));
@@ -264,6 +272,10 @@ const JsHistoricalSimulatorFinalization = (typeof FinalizationRegistry === 'unde
264
272
  ? { register: () => {}, unregister: () => {} }
265
273
  : new FinalizationRegistry(ptr => wasm.__wbg_jshistoricalsimulator_free(ptr >>> 0, 1));
266
274
 
275
+ const JsModelDiagnosticsFinalization = (typeof FinalizationRegistry === 'undefined')
276
+ ? { register: () => {}, unregister: () => {} }
277
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsmodeldiagnostics_free(ptr >>> 0, 1));
278
+
267
279
  const JsNormalPredictorFinalization = (typeof FinalizationRegistry === 'undefined')
268
280
  ? { register: () => {}, unregister: () => {} }
269
281
  : new FinalizationRegistry(ptr => wasm.__wbg_jsnormalpredictor_free(ptr >>> 0, 1));
@@ -272,6 +284,18 @@ const JsNormalResultFinalization = (typeof FinalizationRegistry === 'undefined')
272
284
  ? { register: () => {}, unregister: () => {} }
273
285
  : new FinalizationRegistry(ptr => wasm.__wbg_jsnormalresult_free(ptr >>> 0, 1));
274
286
 
287
+ const JsPipelineBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
288
+ ? { register: () => {}, unregister: () => {} }
289
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspipelinebuilder_free(ptr >>> 0, 1));
290
+
291
+ const JsPipelineReportFinalization = (typeof FinalizationRegistry === 'undefined')
292
+ ? { register: () => {}, unregister: () => {} }
293
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspipelinereport_free(ptr >>> 0, 1));
294
+
295
+ const JsPipelineResultFinalization = (typeof FinalizationRegistry === 'undefined')
296
+ ? { register: () => {}, unregister: () => {} }
297
+ : new FinalizationRegistry(ptr => wasm.__wbg_jspipelineresult_free(ptr >>> 0, 1));
298
+
275
299
  const JsPointForecastsFinalization = (typeof FinalizationRegistry === 'undefined')
276
300
  ? { register: () => {}, unregister: () => {} }
277
301
  : new FinalizationRegistry(ptr => wasm.__wbg_jspointforecasts_free(ptr >>> 0, 1));
@@ -288,6 +312,10 @@ const JsTrainedModelFinalization = (typeof FinalizationRegistry === 'undefined')
288
312
  ? { register: () => {}, unregister: () => {} }
289
313
  : new FinalizationRegistry(ptr => wasm.__wbg_jstrainedmodel_free(ptr >>> 0, 1));
290
314
 
315
+ const KalmanForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
316
+ ? { register: () => {}, unregister: () => {} }
317
+ : new FinalizationRegistry(ptr => wasm.__wbg_kalmanforecaster_free(ptr >>> 0, 1));
318
+
291
319
  const MFLESForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
292
320
  ? { register: () => {}, unregister: () => {} }
293
321
  : new FinalizationRegistry(ptr => wasm.__wbg_mflesforecaster_free(ptr >>> 0, 1));
@@ -352,6 +380,10 @@ const TimeSeriesFinalization = (typeof FinalizationRegistry === 'undefined')
352
380
  ? { register: () => {}, unregister: () => {} }
353
381
  : new FinalizationRegistry(ptr => wasm.__wbg_timeseries_free(ptr >>> 0, 1));
354
382
 
383
+ const VARForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
384
+ ? { register: () => {}, unregister: () => {} }
385
+ : new FinalizationRegistry(ptr => wasm.__wbg_varforecaster_free(ptr >>> 0, 1));
386
+
355
387
  const WindowAverageForecasterFinalization = (typeof FinalizationRegistry === 'undefined')
356
388
  ? { register: () => {}, unregister: () => {} }
357
389
  : new FinalizationRegistry(ptr => wasm.__wbg_windowaverageforecaster_free(ptr >>> 0, 1));
@@ -825,6 +857,113 @@ export class AutoEnsembleForecaster {
825
857
  }
826
858
  if (Symbol.dispose) AutoEnsembleForecaster.prototype[Symbol.dispose] = AutoEnsembleForecaster.prototype.free;
827
859
 
860
+ /**
861
+ * Builder for constructing an AutoForecaster with custom parameters.
862
+ *
863
+ * Uses a fluent API: chain setter methods and call `build()` to produce
864
+ * an `AutoForecaster`.
865
+ */
866
+ export class AutoForecastBuilder {
867
+ static __wrap(ptr) {
868
+ ptr = ptr >>> 0;
869
+ const obj = Object.create(AutoForecastBuilder.prototype);
870
+ obj.__wbg_ptr = ptr;
871
+ AutoForecastBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
872
+ return obj;
873
+ }
874
+ __destroy_into_raw() {
875
+ const ptr = this.__wbg_ptr;
876
+ this.__wbg_ptr = 0;
877
+ AutoForecastBuilderFinalization.unregister(this);
878
+ return ptr;
879
+ }
880
+ free() {
881
+ const ptr = this.__destroy_into_raw();
882
+ wasm.__wbg_autoforecastbuilder_free(ptr, 0);
883
+ }
884
+ /**
885
+ * Include or exclude AutoETS from the candidate set.
886
+ *
887
+ * @param include - Whether to include AutoETS (default: true)
888
+ * @param {boolean} include
889
+ * @returns {AutoForecastBuilder}
890
+ */
891
+ includeEts(include) {
892
+ const ptr = this.__destroy_into_raw();
893
+ const ret = wasm.autoforecastbuilder_includeEts(ptr, include);
894
+ return AutoForecastBuilder.__wrap(ret);
895
+ }
896
+ /**
897
+ * Include or exclude AutoARIMA from the candidate set.
898
+ *
899
+ * @param include - Whether to include AutoARIMA (default: true)
900
+ * @param {boolean} include
901
+ * @returns {AutoForecastBuilder}
902
+ */
903
+ includeArima(include) {
904
+ const ptr = this.__destroy_into_raw();
905
+ const ret = wasm.autoforecastbuilder_includeArima(ptr, include);
906
+ return AutoForecastBuilder.__wrap(ret);
907
+ }
908
+ /**
909
+ * Include or exclude AutoTheta from the candidate set.
910
+ *
911
+ * @param include - Whether to include AutoTheta (default: true)
912
+ * @param {boolean} include
913
+ * @returns {AutoForecastBuilder}
914
+ */
915
+ includeTheta(include) {
916
+ const ptr = this.__destroy_into_raw();
917
+ const ret = wasm.autoforecastbuilder_includeTheta(ptr, include);
918
+ return AutoForecastBuilder.__wrap(ret);
919
+ }
920
+ /**
921
+ * Set the seasonal period.
922
+ *
923
+ * @param period - Seasonal period (e.g., 12 for monthly data)
924
+ * @param {number} period
925
+ * @returns {AutoForecastBuilder}
926
+ */
927
+ seasonalPeriod(period) {
928
+ const ptr = this.__destroy_into_raw();
929
+ const ret = wasm.autoforecastbuilder_seasonalPeriod(ptr, period);
930
+ return AutoForecastBuilder.__wrap(ret);
931
+ }
932
+ /**
933
+ * Use cross-validation instead of in-sample MSE for model selection.
934
+ *
935
+ * @param useCv - Whether to use cross-validation (default: false)
936
+ * @param {boolean} use_cv
937
+ * @returns {AutoForecastBuilder}
938
+ */
939
+ useCrossValidation(use_cv) {
940
+ const ptr = this.__destroy_into_raw();
941
+ const ret = wasm.autoforecastbuilder_useCrossValidation(ptr, use_cv);
942
+ return AutoForecastBuilder.__wrap(ret);
943
+ }
944
+ /**
945
+ * Create a new builder with all defaults enabled.
946
+ */
947
+ constructor() {
948
+ const ret = wasm.autoforecastbuilder_new();
949
+ this.__wbg_ptr = ret >>> 0;
950
+ AutoForecastBuilderFinalization.register(this, this.__wbg_ptr, this);
951
+ return this;
952
+ }
953
+ /**
954
+ * Build the AutoForecaster with the configured parameters.
955
+ *
956
+ * @returns A new AutoForecaster ready to fit
957
+ * @returns {AutoForecaster}
958
+ */
959
+ build() {
960
+ const ptr = this.__destroy_into_raw();
961
+ const ret = wasm.autoforecastbuilder_build(ptr);
962
+ return AutoForecaster.__wrap(ret);
963
+ }
964
+ }
965
+ if (Symbol.dispose) AutoForecastBuilder.prototype[Symbol.dispose] = AutoForecastBuilder.prototype.free;
966
+
828
967
  /**
829
968
  * Automatic model selection across ARIMA, ETS, and Theta families.
830
969
  *
@@ -1688,6 +1827,23 @@ export class EnsembleForecaster {
1688
1827
  setMedian() {
1689
1828
  wasm.ensembleforecaster_setMedian(this.__wbg_ptr);
1690
1829
  }
1830
+ /**
1831
+ * Set the combination method by name string.
1832
+ *
1833
+ * Supported values: "mean", "median", "weighted_mse", "inverse_aic",
1834
+ * "stacking", "horizon_adaptive".
1835
+ *
1836
+ * @param method - Combination method name
1837
+ * @param {string} method
1838
+ */
1839
+ setMethod(method) {
1840
+ const ptr0 = passStringToWasm0(method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1841
+ const len0 = WASM_VECTOR_LEN;
1842
+ const ret = wasm.ensembleforecaster_setMethod(this.__wbg_ptr, ptr0, len0);
1843
+ if (ret[1]) {
1844
+ throw takeFromExternrefTable0(ret[0]);
1845
+ }
1846
+ }
1691
1847
  /**
1692
1848
  * Get the number of models in the ensemble.
1693
1849
  * @returns {number}
@@ -1709,12 +1865,40 @@ export class EnsembleForecaster {
1709
1865
  const len0 = WASM_VECTOR_LEN;
1710
1866
  wasm.ensembleforecaster_setWeights(this.__wbg_ptr, ptr0, len0);
1711
1867
  }
1868
+ /**
1869
+ * Set the combination method to stacking (projected gradient descent).
1870
+ *
1871
+ * Trains non-negative weights that sum to one on validation data.
1872
+ *
1873
+ * @param folds - Number of folds (default: 5)
1874
+ * @param {number | null} [folds]
1875
+ */
1876
+ setStacking(folds) {
1877
+ wasm.ensembleforecaster_setStacking(this.__wbg_ptr, isLikeNone(folds) ? 0x100000001 : (folds) >>> 0);
1878
+ }
1879
+ /**
1880
+ * Set the combination method to inverse AIC weighting.
1881
+ *
1882
+ * Computes Akaike weights from in-sample residuals.
1883
+ */
1884
+ setInverseAic() {
1885
+ wasm.ensembleforecaster_setInverseAic(this.__wbg_ptr);
1886
+ }
1712
1887
  /**
1713
1888
  * Set the combination method to weighted MSE.
1714
1889
  */
1715
1890
  setWeightedMse() {
1716
1891
  wasm.ensembleforecaster_setWeightedMse(this.__wbg_ptr);
1717
1892
  }
1893
+ /**
1894
+ * Set the combination method to per-horizon adaptive weighting.
1895
+ *
1896
+ * Computes separate weight vectors for each forecast horizon step
1897
+ * based on rolling-origin evaluation.
1898
+ */
1899
+ setHorizonAdaptive() {
1900
+ wasm.ensembleforecaster_setHorizonAdaptive(this.__wbg_ptr);
1901
+ }
1718
1902
  /**
1719
1903
  * Predict with prediction intervals.
1720
1904
  *
@@ -1822,6 +2006,36 @@ export class Forecast {
1822
2006
  const ptr = this.__destroy_into_raw();
1823
2007
  wasm.__wbg_forecast_free(ptr, 0);
1824
2008
  }
2009
+ /**
2010
+ * Return a new forecast with all values clamped to be non-negative.
2011
+ * @returns {Forecast}
2012
+ */
2013
+ nonNegative() {
2014
+ const ret = wasm.forecast_nonNegative(this.__wbg_ptr);
2015
+ return Forecast.__wrap(ret);
2016
+ }
2017
+ /**
2018
+ * Return a new forecast with point values rounded to the nearest integer,
2019
+ * lower intervals floored, and upper intervals ceiled.
2020
+ * @returns {Forecast}
2021
+ */
2022
+ roundToInteger() {
2023
+ const ret = wasm.forecast_roundToInteger(this.__wbg_ptr);
2024
+ return Forecast.__wrap(ret);
2025
+ }
2026
+ /**
2027
+ * Return a new forecast with all values clamped to `[lower, upper]`.
2028
+ *
2029
+ * @param lower - Lower bound
2030
+ * @param upper - Upper bound
2031
+ * @param {number} lower
2032
+ * @param {number} upper
2033
+ * @returns {Forecast}
2034
+ */
2035
+ clamp(lower, upper) {
2036
+ const ret = wasm.forecast_clamp(this.__wbg_ptr, lower, upper);
2037
+ return Forecast.__wrap(ret);
2038
+ }
1825
2039
  /**
1826
2040
  * Get lower prediction interval bounds.
1827
2041
  *
@@ -2513,256 +2727,1205 @@ export class JsConformalResult {
2513
2727
  if (Symbol.dispose) JsConformalResult.prototype[Symbol.dispose] = JsConformalResult.prototype.free;
2514
2728
 
2515
2729
  /**
2516
- * Historical simulation resultstores the empirical error distribution.
2730
+ * Automated data profilestationarity, trend, seasonality, quality score.
2731
+ *
2732
+ * Profile a time series to understand its characteristics before model selection.
2517
2733
  */
2518
- export class JsHistoricalSimResult {
2734
+ export class JsDataProfile {
2519
2735
  static __wrap(ptr) {
2520
2736
  ptr = ptr >>> 0;
2521
- const obj = Object.create(JsHistoricalSimResult.prototype);
2737
+ const obj = Object.create(JsDataProfile.prototype);
2522
2738
  obj.__wbg_ptr = ptr;
2523
- JsHistoricalSimResultFinalization.register(obj, obj.__wbg_ptr, obj);
2739
+ JsDataProfileFinalization.register(obj, obj.__wbg_ptr, obj);
2524
2740
  return obj;
2525
2741
  }
2526
2742
  __destroy_into_raw() {
2527
2743
  const ptr = this.__wbg_ptr;
2528
2744
  this.__wbg_ptr = 0;
2529
- JsHistoricalSimResultFinalization.unregister(this);
2745
+ JsDataProfileFinalization.unregister(this);
2530
2746
  return ptr;
2531
2747
  }
2532
2748
  free() {
2533
2749
  const ptr = this.__destroy_into_raw();
2534
- wasm.__wbg_jshistoricalsimresult_free(ptr, 0);
2750
+ wasm.__wbg_jsdataprofile_free(ptr, 0);
2535
2751
  }
2536
2752
  /**
2537
- * Get the quantile values.
2538
- * @returns {Float64Array}
2753
+ * Whether every finite value is integer-valued.
2754
+ * @returns {boolean}
2539
2755
  */
2540
- quantileValues() {
2541
- const ret = wasm.jshistoricalsimresult_quantileValues(this.__wbg_ptr);
2542
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2543
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2544
- return v1;
2756
+ get isInteger() {
2757
+ const ret = wasm.jsdataprofile_isInteger(this.__wbg_ptr);
2758
+ return ret !== 0;
2545
2759
  }
2546
2760
  /**
2547
- * Get the sorted errors.
2548
- * @returns {Float64Array}
2761
+ * Lempel-Ziv complexity (normalized).
2762
+ * @returns {number}
2549
2763
  */
2550
- errors() {
2551
- const ret = wasm.jshistoricalsimresult_errors(this.__wbg_ptr);
2552
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2553
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2554
- return v1;
2555
- }
2556
- }
2557
- if (Symbol.dispose) JsHistoricalSimResult.prototype[Symbol.dispose] = JsHistoricalSimResult.prototype.free;
2558
-
2559
- /**
2560
- * Historical simulator — non-parametric prediction intervals
2561
- * based on the empirical error distribution.
2562
- */
2563
- export class JsHistoricalSimulator {
2564
- static __wrap(ptr) {
2565
- ptr = ptr >>> 0;
2566
- const obj = Object.create(JsHistoricalSimulator.prototype);
2567
- obj.__wbg_ptr = ptr;
2568
- JsHistoricalSimulatorFinalization.register(obj, obj.__wbg_ptr, obj);
2569
- return obj;
2570
- }
2571
- __destroy_into_raw() {
2572
- const ptr = this.__wbg_ptr;
2573
- this.__wbg_ptr = 0;
2574
- JsHistoricalSimulatorFinalization.unregister(this);
2575
- return ptr;
2576
- }
2577
- free() {
2578
- const ptr = this.__destroy_into_raw();
2579
- wasm.__wbg_jshistoricalsimulator_free(ptr, 0);
2764
+ get lempelZiv() {
2765
+ const ret = wasm.jsdataprofile_lempelZiv(this.__wbg_ptr);
2766
+ return ret;
2580
2767
  }
2581
2768
  /**
2582
- * Create a simulator with a rolling window.
2583
- *
2584
- * @param quantiles - Sorted quantile levels in (0,1)
2585
- * @param window - Number of recent observations to use
2586
- * @param {Float64Array} quantiles
2587
- * @param {number} window
2588
- * @returns {JsHistoricalSimulator}
2769
+ * ADF p-value.
2770
+ * @returns {number}
2589
2771
  */
2590
- static withWindow(quantiles, window) {
2591
- const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2592
- const len0 = WASM_VECTOR_LEN;
2593
- const ret = wasm.jshistoricalsimulator_withWindow(ptr0, len0, window);
2594
- return JsHistoricalSimulator.__wrap(ret);
2772
+ get adfPValue() {
2773
+ const ret = wasm.jsdataprofile_adfPValue(this.__wbg_ptr);
2774
+ return ret;
2595
2775
  }
2596
2776
  /**
2597
- * Generate prediction intervals for new point forecasts.
2777
+ * Profile a time series.
2598
2778
  *
2599
- * @param result - A fitted JsHistoricalSimResult from simulate()
2600
- * @param pointForecasts - New point forecast values
2601
- * @param {JsHistoricalSimResult} result
2602
- * @param {Float64Array} point_forecasts
2603
- * @returns {JsPredictionIntervals}
2779
+ * @param series - TimeSeries to profile
2780
+ * @returns A comprehensive data profile
2781
+ * @param {TimeSeries} series
2782
+ * @returns {JsDataProfile}
2604
2783
  */
2605
- predictIntervals(result, point_forecasts) {
2606
- _assertClass(result, JsHistoricalSimResult);
2607
- const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
2608
- const len0 = WASM_VECTOR_LEN;
2609
- const ret = wasm.jshistoricalsimulator_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
2610
- if (ret[2]) {
2611
- throw takeFromExternrefTable0(ret[1]);
2612
- }
2613
- return JsPredictionIntervals.__wrap(ret[0]);
2784
+ static fromSeries(series) {
2785
+ _assertClass(series, TimeSeries);
2786
+ const ret = wasm.jsdataprofile_fromSeries(series.__wbg_ptr);
2787
+ return JsDataProfile.__wrap(ret);
2614
2788
  }
2615
2789
  /**
2616
- * Create a new historical simulator.
2790
+ * Profile raw values (without timestamps).
2617
2791
  *
2618
- * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
2619
- * @param {Float64Array} quantiles
2792
+ * @param values - Array of numeric values
2793
+ * @returns A data profile
2794
+ * @param {Float64Array} values
2795
+ * @returns {JsDataProfile}
2620
2796
  */
2621
- constructor(quantiles) {
2622
- const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2797
+ static fromValues(values) {
2798
+ const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
2623
2799
  const len0 = WASM_VECTOR_LEN;
2624
- const ret = wasm.jshistoricalsimulator_new(ptr0, len0);
2625
- this.__wbg_ptr = ret >>> 0;
2626
- JsHistoricalSimulatorFinalization.register(this, this.__wbg_ptr, this);
2627
- return this;
2800
+ const ret = wasm.jsdataprofile_fromValues(ptr0, len0);
2801
+ return JsDataProfile.__wrap(ret);
2628
2802
  }
2629
2803
  /**
2630
- * Fit the simulator on historical forecasts and actuals.
2631
- *
2632
- * @param forecasts - Historical point forecast values
2633
- * @param actuals - Corresponding actual observed values
2634
- * @param {Float64Array} forecasts
2635
- * @param {Float64Array} actuals
2636
- * @returns {JsHistoricalSimResult}
2804
+ * Slope of the linear trend.
2805
+ * @returns {number}
2637
2806
  */
2638
- simulate(forecasts, actuals) {
2639
- const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
2640
- const len0 = WASM_VECTOR_LEN;
2641
- const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2642
- const len1 = WASM_VECTOR_LEN;
2643
- const ret = wasm.jshistoricalsimulator_simulate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2644
- if (ret[2]) {
2645
- throw takeFromExternrefTable0(ret[1]);
2646
- }
2647
- return JsHistoricalSimResult.__wrap(ret[0]);
2648
- }
2649
- }
2650
- if (Symbol.dispose) JsHistoricalSimulator.prototype[Symbol.dispose] = JsHistoricalSimulator.prototype.free;
2651
-
2652
- /**
2653
- * Normal predictor — assumes Gaussian forecast errors.
2654
- *
2655
- * Generates quantile-based prediction intervals from the estimated
2656
- * error mean and standard deviation.
2657
- */
2658
- export class JsNormalPredictor {
2659
- __destroy_into_raw() {
2660
- const ptr = this.__wbg_ptr;
2661
- this.__wbg_ptr = 0;
2662
- JsNormalPredictorFinalization.unregister(this);
2663
- return ptr;
2807
+ get trendSlope() {
2808
+ const ret = wasm.jsdataprofile_trendSlope(this.__wbg_ptr);
2809
+ return ret;
2664
2810
  }
2665
- free() {
2666
- const ptr = this.__destroy_into_raw();
2667
- wasm.__wbg_jsnormalpredictor_free(ptr, 0);
2811
+ /**
2812
+ * KPSS p-value.
2813
+ * @returns {number}
2814
+ */
2815
+ get kpssPValue() {
2816
+ const ret = wasm.jsdataprofile_kpssPValue(this.__wbg_ptr);
2817
+ return ret;
2668
2818
  }
2669
2819
  /**
2670
- * Generate prediction intervals for new point forecasts.
2671
- *
2672
- * Returns intervals using the first and last quantile as bounds.
2673
- *
2674
- * @param result - A fitted JsNormalResult from fit()
2675
- * @param pointForecasts - New point forecast values
2676
- * @param {JsNormalResult} result
2677
- * @param {Float64Array} point_forecasts
2678
- * @returns {JsPredictionIntervals}
2820
+ * Full profile as a formatted string.
2821
+ * @returns {string}
2679
2822
  */
2680
- predictIntervals(result, point_forecasts) {
2681
- _assertClass(result, JsNormalResult);
2682
- const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
2823
+ toString() {
2824
+ let deferred1_0;
2825
+ let deferred1_1;
2826
+ try {
2827
+ const ret = wasm.jsdataprofile_toString(this.__wbg_ptr);
2828
+ deferred1_0 = ret[0];
2829
+ deferred1_1 = ret[1];
2830
+ return getStringFromWasm0(ret[0], ret[1]);
2831
+ } finally {
2832
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2833
+ }
2834
+ }
2835
+ /**
2836
+ * ADF test statistic.
2837
+ * @returns {number}
2838
+ */
2839
+ get adfStatistic() {
2840
+ const ret = wasm.jsdataprofile_adfStatistic(this.__wbg_ptr);
2841
+ return ret;
2842
+ }
2843
+ /**
2844
+ * Whether any value is negative.
2845
+ * @returns {boolean}
2846
+ */
2847
+ get hasNegatives() {
2848
+ const ret = wasm.jsdataprofile_hasNegatives(this.__wbg_ptr);
2849
+ return ret !== 0;
2850
+ }
2851
+ /**
2852
+ * Combined stationarity (ADF stationary AND KPSS stationary).
2853
+ * @returns {boolean}
2854
+ */
2855
+ get isStationary() {
2856
+ const ret = wasm.jsdataprofile_isStationary(this.__wbg_ptr);
2857
+ return ret !== 0;
2858
+ }
2859
+ /**
2860
+ * Count of NaN or infinite values.
2861
+ * @returns {number}
2862
+ */
2863
+ get missingCount() {
2864
+ const ret = wasm.jsdataprofile_missingCount(this.__wbg_ptr);
2865
+ return ret >>> 0;
2866
+ }
2867
+ /**
2868
+ * Heuristic data-quality score in [0.0, 1.0].
2869
+ * @returns {number}
2870
+ */
2871
+ get qualityScore() {
2872
+ const ret = wasm.jsdataprofile_qualityScore(this.__wbg_ptr);
2873
+ return ret;
2874
+ }
2875
+ /**
2876
+ * Fraction of values that are exactly zero.
2877
+ * @returns {number}
2878
+ */
2879
+ get zeroFraction() {
2880
+ const ret = wasm.jsdataprofile_zeroFraction(this.__wbg_ptr);
2881
+ return ret;
2882
+ }
2883
+ /**
2884
+ * KPSS test statistic.
2885
+ * @returns {number}
2886
+ */
2887
+ get kpssStatistic() {
2888
+ const ret = wasm.jsdataprofile_kpssStatistic(this.__wbg_ptr);
2889
+ return ret;
2890
+ }
2891
+ /**
2892
+ * Number of observations.
2893
+ * @returns {number}
2894
+ */
2895
+ get nObservations() {
2896
+ const ret = wasm.jsdataprofile_nObservations(this.__wbg_ptr);
2897
+ return ret >>> 0;
2898
+ }
2899
+ /**
2900
+ * Trend strength (R-squared, 0.0 to 1.0).
2901
+ * @returns {number}
2902
+ */
2903
+ get trendStrength() {
2904
+ const ret = wasm.jsdataprofile_trendStrength(this.__wbg_ptr);
2905
+ return ret;
2906
+ }
2907
+ /**
2908
+ * Whether the series is classified as intermittent.
2909
+ * @returns {boolean}
2910
+ */
2911
+ get isIntermittent() {
2912
+ const ret = wasm.jsdataprofile_isIntermittent(this.__wbg_ptr);
2913
+ return ret !== 0;
2914
+ }
2915
+ /**
2916
+ * Trend direction: "Rising", "Falling", or "Flat".
2917
+ * @returns {string}
2918
+ */
2919
+ get trendDirection() {
2920
+ let deferred1_0;
2921
+ let deferred1_1;
2922
+ try {
2923
+ const ret = wasm.jsdataprofile_trendDirection(this.__wbg_ptr);
2924
+ deferred1_0 = ret[0];
2925
+ deferred1_1 = ret[1];
2926
+ return getStringFromWasm0(ret[0], ret[1]);
2927
+ } finally {
2928
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2929
+ }
2930
+ }
2931
+ /**
2932
+ * Partial autocorrelation at lag 1.
2933
+ * @returns {number}
2934
+ */
2935
+ get partialAcfLag1() {
2936
+ const ret = wasm.jsdataprofile_partialAcfLag1(this.__wbg_ptr);
2937
+ return ret;
2938
+ }
2939
+ /**
2940
+ * Whether ADF concludes stationarity at 5%.
2941
+ * @returns {boolean}
2942
+ */
2943
+ get adfIsStationary() {
2944
+ const ret = wasm.jsdataprofile_adfIsStationary(this.__wbg_ptr);
2945
+ return ret !== 0;
2946
+ }
2947
+ /**
2948
+ * Whether KPSS concludes stationarity at 5%.
2949
+ * @returns {boolean}
2950
+ */
2951
+ get kpssIsStationary() {
2952
+ const ret = wasm.jsdataprofile_kpssIsStationary(this.__wbg_ptr);
2953
+ return ret !== 0;
2954
+ }
2955
+ /**
2956
+ * Approximate entropy (undefined if series is too short).
2957
+ * @returns {number | undefined}
2958
+ */
2959
+ get approximateEntropy() {
2960
+ const ret = wasm.jsdataprofile_approximateEntropy(this.__wbg_ptr);
2961
+ return ret[0] === 0 ? undefined : ret[1];
2962
+ }
2963
+ /**
2964
+ * Maximum value.
2965
+ * @returns {number}
2966
+ */
2967
+ get max() {
2968
+ const ret = wasm.jsdataprofile_max(this.__wbg_ptr);
2969
+ return ret;
2970
+ }
2971
+ /**
2972
+ * Minimum value.
2973
+ * @returns {number}
2974
+ */
2975
+ get min() {
2976
+ const ret = wasm.jsdataprofile_min(this.__wbg_ptr);
2977
+ return ret;
2978
+ }
2979
+ /**
2980
+ * Arithmetic mean.
2981
+ * @returns {number}
2982
+ */
2983
+ get mean() {
2984
+ const ret = wasm.jsconformalresult_quantileValue(this.__wbg_ptr);
2985
+ return ret;
2986
+ }
2987
+ /**
2988
+ * Standard deviation.
2989
+ * @returns {number}
2990
+ */
2991
+ get stdDev() {
2992
+ const ret = wasm.jsconformalresult_coverage(this.__wbg_ptr);
2993
+ return ret;
2994
+ }
2995
+ /**
2996
+ * Human-readable summary string.
2997
+ * @returns {string}
2998
+ */
2999
+ summary() {
3000
+ let deferred1_0;
3001
+ let deferred1_1;
3002
+ try {
3003
+ const ret = wasm.jsdataprofile_summary(this.__wbg_ptr);
3004
+ deferred1_0 = ret[0];
3005
+ deferred1_1 = ret[1];
3006
+ return getStringFromWasm0(ret[0], ret[1]);
3007
+ } finally {
3008
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3009
+ }
3010
+ }
3011
+ /**
3012
+ * Profile as a JSON-serializable object.
3013
+ * @returns {any}
3014
+ */
3015
+ toJSON() {
3016
+ const ret = wasm.jsdataprofile_toJSON(this.__wbg_ptr);
3017
+ if (ret[2]) {
3018
+ throw takeFromExternrefTable0(ret[1]);
3019
+ }
3020
+ return takeFromExternrefTable0(ret[0]);
3021
+ }
3022
+ /**
3023
+ * Autocorrelation at lag 1.
3024
+ * @returns {number}
3025
+ */
3026
+ get acfLag1() {
3027
+ const ret = wasm.jsdataprofile_acfLag1(this.__wbg_ptr);
3028
+ return ret;
3029
+ }
3030
+ /**
3031
+ * Autocorrelation at lag 2.
3032
+ * @returns {number}
3033
+ */
3034
+ get acfLag2() {
3035
+ const ret = wasm.jsdataprofile_acfLag2(this.__wbg_ptr);
3036
+ return ret;
3037
+ }
3038
+ /**
3039
+ * Excess kurtosis.
3040
+ * @returns {number}
3041
+ */
3042
+ get kurtosis() {
3043
+ const ret = wasm.jsdataprofile_kurtosis(this.__wbg_ptr);
3044
+ return ret;
3045
+ }
3046
+ /**
3047
+ * Skewness.
3048
+ * @returns {number}
3049
+ */
3050
+ get skewness() {
3051
+ const ret = wasm.jsdataprofile_skewness(this.__wbg_ptr);
3052
+ return ret;
3053
+ }
3054
+ }
3055
+ if (Symbol.dispose) JsDataProfile.prototype[Symbol.dispose] = JsDataProfile.prototype.free;
3056
+
3057
+ /**
3058
+ * Historical simulation result — stores the empirical error distribution.
3059
+ */
3060
+ export class JsHistoricalSimResult {
3061
+ static __wrap(ptr) {
3062
+ ptr = ptr >>> 0;
3063
+ const obj = Object.create(JsHistoricalSimResult.prototype);
3064
+ obj.__wbg_ptr = ptr;
3065
+ JsHistoricalSimResultFinalization.register(obj, obj.__wbg_ptr, obj);
3066
+ return obj;
3067
+ }
3068
+ __destroy_into_raw() {
3069
+ const ptr = this.__wbg_ptr;
3070
+ this.__wbg_ptr = 0;
3071
+ JsHistoricalSimResultFinalization.unregister(this);
3072
+ return ptr;
3073
+ }
3074
+ free() {
3075
+ const ptr = this.__destroy_into_raw();
3076
+ wasm.__wbg_jshistoricalsimresult_free(ptr, 0);
3077
+ }
3078
+ /**
3079
+ * Get the quantile values.
3080
+ * @returns {Float64Array}
3081
+ */
3082
+ quantileValues() {
3083
+ const ret = wasm.jshistoricalsimresult_quantileValues(this.__wbg_ptr);
3084
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3085
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3086
+ return v1;
3087
+ }
3088
+ /**
3089
+ * Get the sorted errors.
3090
+ * @returns {Float64Array}
3091
+ */
3092
+ errors() {
3093
+ const ret = wasm.jshistoricalsimresult_errors(this.__wbg_ptr);
3094
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3095
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3096
+ return v1;
3097
+ }
3098
+ }
3099
+ if (Symbol.dispose) JsHistoricalSimResult.prototype[Symbol.dispose] = JsHistoricalSimResult.prototype.free;
3100
+
3101
+ /**
3102
+ * Historical simulator — non-parametric prediction intervals
3103
+ * based on the empirical error distribution.
3104
+ */
3105
+ export class JsHistoricalSimulator {
3106
+ static __wrap(ptr) {
3107
+ ptr = ptr >>> 0;
3108
+ const obj = Object.create(JsHistoricalSimulator.prototype);
3109
+ obj.__wbg_ptr = ptr;
3110
+ JsHistoricalSimulatorFinalization.register(obj, obj.__wbg_ptr, obj);
3111
+ return obj;
3112
+ }
3113
+ __destroy_into_raw() {
3114
+ const ptr = this.__wbg_ptr;
3115
+ this.__wbg_ptr = 0;
3116
+ JsHistoricalSimulatorFinalization.unregister(this);
3117
+ return ptr;
3118
+ }
3119
+ free() {
3120
+ const ptr = this.__destroy_into_raw();
3121
+ wasm.__wbg_jshistoricalsimulator_free(ptr, 0);
3122
+ }
3123
+ /**
3124
+ * Create a simulator with a rolling window.
3125
+ *
3126
+ * @param quantiles - Sorted quantile levels in (0,1)
3127
+ * @param window - Number of recent observations to use
3128
+ * @param {Float64Array} quantiles
3129
+ * @param {number} window
3130
+ * @returns {JsHistoricalSimulator}
3131
+ */
3132
+ static withWindow(quantiles, window) {
3133
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
3134
+ const len0 = WASM_VECTOR_LEN;
3135
+ const ret = wasm.jshistoricalsimulator_withWindow(ptr0, len0, window);
3136
+ return JsHistoricalSimulator.__wrap(ret);
3137
+ }
3138
+ /**
3139
+ * Generate prediction intervals for new point forecasts.
3140
+ *
3141
+ * @param result - A fitted JsHistoricalSimResult from simulate()
3142
+ * @param pointForecasts - New point forecast values
3143
+ * @param {JsHistoricalSimResult} result
3144
+ * @param {Float64Array} point_forecasts
3145
+ * @returns {JsPredictionIntervals}
3146
+ */
3147
+ predictIntervals(result, point_forecasts) {
3148
+ _assertClass(result, JsHistoricalSimResult);
3149
+ const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
3150
+ const len0 = WASM_VECTOR_LEN;
3151
+ const ret = wasm.jshistoricalsimulator_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
3152
+ if (ret[2]) {
3153
+ throw takeFromExternrefTable0(ret[1]);
3154
+ }
3155
+ return JsPredictionIntervals.__wrap(ret[0]);
3156
+ }
3157
+ /**
3158
+ * Create a new historical simulator.
3159
+ *
3160
+ * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
3161
+ * @param {Float64Array} quantiles
3162
+ */
3163
+ constructor(quantiles) {
3164
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
3165
+ const len0 = WASM_VECTOR_LEN;
3166
+ const ret = wasm.jshistoricalsimulator_new(ptr0, len0);
3167
+ this.__wbg_ptr = ret >>> 0;
3168
+ JsHistoricalSimulatorFinalization.register(this, this.__wbg_ptr, this);
3169
+ return this;
3170
+ }
3171
+ /**
3172
+ * Fit the simulator on historical forecasts and actuals.
3173
+ *
3174
+ * @param forecasts - Historical point forecast values
3175
+ * @param actuals - Corresponding actual observed values
3176
+ * @param {Float64Array} forecasts
3177
+ * @param {Float64Array} actuals
3178
+ * @returns {JsHistoricalSimResult}
3179
+ */
3180
+ simulate(forecasts, actuals) {
3181
+ const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
3182
+ const len0 = WASM_VECTOR_LEN;
3183
+ const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
3184
+ const len1 = WASM_VECTOR_LEN;
3185
+ const ret = wasm.jshistoricalsimulator_simulate(this.__wbg_ptr, ptr0, len0, ptr1, len1);
3186
+ if (ret[2]) {
3187
+ throw takeFromExternrefTable0(ret[1]);
3188
+ }
3189
+ return JsHistoricalSimResult.__wrap(ret[0]);
3190
+ }
3191
+ }
3192
+ if (Symbol.dispose) JsHistoricalSimulator.prototype[Symbol.dispose] = JsHistoricalSimulator.prototype.free;
3193
+
3194
+ /**
3195
+ * Complete model diagnostics report.
3196
+ *
3197
+ * Includes Ljung-Box, Jarque-Bera, and Breusch-Pagan tests, plus
3198
+ * residual ACF/PACF and summary statistics.
3199
+ */
3200
+ export class JsModelDiagnostics {
3201
+ static __wrap(ptr) {
3202
+ ptr = ptr >>> 0;
3203
+ const obj = Object.create(JsModelDiagnostics.prototype);
3204
+ obj.__wbg_ptr = ptr;
3205
+ JsModelDiagnosticsFinalization.register(obj, obj.__wbg_ptr, obj);
3206
+ return obj;
3207
+ }
3208
+ __destroy_into_raw() {
3209
+ const ptr = this.__wbg_ptr;
3210
+ this.__wbg_ptr = 0;
3211
+ JsModelDiagnosticsFinalization.unregister(this);
3212
+ return ptr;
3213
+ }
3214
+ free() {
3215
+ const ptr = this.__destroy_into_raw();
3216
+ wasm.__wbg_jsmodeldiagnostics_free(ptr, 0);
3217
+ }
3218
+ /**
3219
+ * Whether all diagnostic tests pass at the configured significance level.
3220
+ * @returns {boolean}
3221
+ */
3222
+ get passesAll() {
3223
+ const ret = wasm.jsmodeldiagnostics_passesAll(this.__wbg_ptr);
3224
+ return ret !== 0;
3225
+ }
3226
+ /**
3227
+ * Autocorrelation function of the residuals.
3228
+ * @returns {Float64Array}
3229
+ */
3230
+ get residualAcf() {
3231
+ const ret = wasm.jsmodeldiagnostics_residualAcf(this.__wbg_ptr);
3232
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3233
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3234
+ return v1;
3235
+ }
3236
+ /**
3237
+ * Standard deviation of the residuals.
3238
+ * @returns {number}
3239
+ */
3240
+ get residualStd() {
3241
+ const ret = wasm.jsdataprofile_max(this.__wbg_ptr);
3242
+ return ret;
3243
+ }
3244
+ /**
3245
+ * Mean of the residuals.
3246
+ * @returns {number}
3247
+ */
3248
+ get residualMean() {
3249
+ const ret = wasm.jsdataprofile_min(this.__wbg_ptr);
3250
+ return ret;
3251
+ }
3252
+ /**
3253
+ * Partial autocorrelation function of the residuals.
3254
+ * @returns {Float64Array}
3255
+ */
3256
+ get residualPacf() {
3257
+ const ret = wasm.jsmodeldiagnostics_residualPacf(this.__wbg_ptr);
3258
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3259
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3260
+ return v1;
3261
+ }
3262
+ /**
3263
+ * Create diagnostics from an array of residuals.
3264
+ *
3265
+ * @param residuals - Array of model residuals
3266
+ * @param significance - Significance level for tests (e.g., 0.05)
3267
+ * @param {Float64Array} residuals
3268
+ * @param {number} significance
3269
+ * @returns {JsModelDiagnostics}
3270
+ */
3271
+ static fromResiduals(residuals, significance) {
3272
+ const ptr0 = passArrayF64ToWasm0(residuals, wasm.__wbindgen_malloc);
3273
+ const len0 = WASM_VECTOR_LEN;
3274
+ const ret = wasm.jsmodeldiagnostics_fromResiduals(ptr0, len0, significance);
3275
+ return JsModelDiagnostics.__wrap(ret);
3276
+ }
3277
+ /**
3278
+ * Number of lags used in the Ljung-Box test.
3279
+ * @returns {number}
3280
+ */
3281
+ get ljungBoxLags() {
3282
+ const ret = wasm.jsmodeldiagnostics_ljungBoxLags(this.__wbg_ptr);
3283
+ return ret >>> 0;
3284
+ }
3285
+ /**
3286
+ * Ljung-Box test p-value for autocorrelation.
3287
+ * @returns {number}
3288
+ */
3289
+ get ljungBoxPvalue() {
3290
+ const ret = wasm.jsmodeldiagnostics_ljungBoxPvalue(this.__wbg_ptr);
3291
+ return ret;
3292
+ }
3293
+ /**
3294
+ * Jarque-Bera test p-value.
3295
+ * @returns {number}
3296
+ */
3297
+ get jarqueBeraPvalue() {
3298
+ const ret = wasm.jsconformalresult_quantileValue(this.__wbg_ptr);
3299
+ return ret;
3300
+ }
3301
+ /**
3302
+ * Jarque-Bera test statistic for normality.
3303
+ * @returns {number}
3304
+ */
3305
+ get jarqueBeraStatistic() {
3306
+ const ret = wasm.jsmodeldiagnostics_jarqueBeraStatistic(this.__wbg_ptr);
3307
+ return ret;
3308
+ }
3309
+ /**
3310
+ * Breusch-Pagan heteroscedasticity test p-value.
3311
+ * @returns {number}
3312
+ */
3313
+ get heteroscedasticityPvalue() {
3314
+ const ret = wasm.jsconformalresult_coverage(this.__wbg_ptr);
3315
+ return ret;
3316
+ }
3317
+ /**
3318
+ * Get a human-readable summary of the diagnostics.
3319
+ * @returns {string}
3320
+ */
3321
+ summary() {
3322
+ let deferred1_0;
3323
+ let deferred1_1;
3324
+ try {
3325
+ const ret = wasm.jsmodeldiagnostics_summary(this.__wbg_ptr);
3326
+ deferred1_0 = ret[0];
3327
+ deferred1_1 = ret[1];
3328
+ return getStringFromWasm0(ret[0], ret[1]);
3329
+ } finally {
3330
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3331
+ }
3332
+ }
3333
+ }
3334
+ if (Symbol.dispose) JsModelDiagnostics.prototype[Symbol.dispose] = JsModelDiagnostics.prototype.free;
3335
+
3336
+ /**
3337
+ * Normal predictor — assumes Gaussian forecast errors.
3338
+ *
3339
+ * Generates quantile-based prediction intervals from the estimated
3340
+ * error mean and standard deviation.
3341
+ */
3342
+ export class JsNormalPredictor {
3343
+ __destroy_into_raw() {
3344
+ const ptr = this.__wbg_ptr;
3345
+ this.__wbg_ptr = 0;
3346
+ JsNormalPredictorFinalization.unregister(this);
3347
+ return ptr;
3348
+ }
3349
+ free() {
3350
+ const ptr = this.__destroy_into_raw();
3351
+ wasm.__wbg_jsnormalpredictor_free(ptr, 0);
3352
+ }
3353
+ /**
3354
+ * Generate prediction intervals for new point forecasts.
3355
+ *
3356
+ * Returns intervals using the first and last quantile as bounds.
3357
+ *
3358
+ * @param result - A fitted JsNormalResult from fit()
3359
+ * @param pointForecasts - New point forecast values
3360
+ * @param {JsNormalResult} result
3361
+ * @param {Float64Array} point_forecasts
3362
+ * @returns {JsPredictionIntervals}
3363
+ */
3364
+ predictIntervals(result, point_forecasts) {
3365
+ _assertClass(result, JsNormalResult);
3366
+ const ptr0 = passArrayF64ToWasm0(point_forecasts, wasm.__wbindgen_malloc);
3367
+ const len0 = WASM_VECTOR_LEN;
3368
+ const ret = wasm.jsnormalpredictor_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
3369
+ if (ret[2]) {
3370
+ throw takeFromExternrefTable0(ret[1]);
3371
+ }
3372
+ return JsPredictionIntervals.__wrap(ret[0]);
3373
+ }
3374
+ /**
3375
+ * Fit the predictor on historical forecasts and actuals.
3376
+ *
3377
+ * @param forecasts - Historical point forecast values
3378
+ * @param actuals - Corresponding actual observed values
3379
+ * @param {Float64Array} forecasts
3380
+ * @param {Float64Array} actuals
3381
+ * @returns {JsNormalResult}
3382
+ */
3383
+ fit(forecasts, actuals) {
3384
+ const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
3385
+ const len0 = WASM_VECTOR_LEN;
3386
+ const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
3387
+ const len1 = WASM_VECTOR_LEN;
3388
+ const ret = wasm.jsnormalpredictor_fit(this.__wbg_ptr, ptr0, len0, ptr1, len1);
3389
+ if (ret[2]) {
3390
+ throw takeFromExternrefTable0(ret[1]);
3391
+ }
3392
+ return JsNormalResult.__wrap(ret[0]);
3393
+ }
3394
+ /**
3395
+ * Create a new normal predictor.
3396
+ *
3397
+ * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
3398
+ * @param {Float64Array} quantiles
3399
+ */
3400
+ constructor(quantiles) {
3401
+ const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
3402
+ const len0 = WASM_VECTOR_LEN;
3403
+ const ret = wasm.jsnormalpredictor_new(ptr0, len0);
3404
+ this.__wbg_ptr = ret >>> 0;
3405
+ JsNormalPredictorFinalization.register(this, this.__wbg_ptr, this);
3406
+ return this;
3407
+ }
3408
+ }
3409
+ if (Symbol.dispose) JsNormalPredictor.prototype[Symbol.dispose] = JsNormalPredictor.prototype.free;
3410
+
3411
+ /**
3412
+ * Normal prediction result — stores Gaussian fit parameters.
3413
+ */
3414
+ export class JsNormalResult {
3415
+ static __wrap(ptr) {
3416
+ ptr = ptr >>> 0;
3417
+ const obj = Object.create(JsNormalResult.prototype);
3418
+ obj.__wbg_ptr = ptr;
3419
+ JsNormalResultFinalization.register(obj, obj.__wbg_ptr, obj);
3420
+ return obj;
3421
+ }
3422
+ __destroy_into_raw() {
3423
+ const ptr = this.__wbg_ptr;
3424
+ this.__wbg_ptr = 0;
3425
+ JsNormalResultFinalization.unregister(this);
3426
+ return ptr;
3427
+ }
3428
+ free() {
3429
+ const ptr = this.__destroy_into_raw();
3430
+ wasm.__wbg_jsnormalresult_free(ptr, 0);
3431
+ }
3432
+ /**
3433
+ * Get the mean error (bias).
3434
+ * @returns {number}
3435
+ */
3436
+ get mean() {
3437
+ const ret = wasm.jsmodeldiagnostics_ljungBoxPvalue(this.__wbg_ptr);
3438
+ return ret;
3439
+ }
3440
+ /**
3441
+ * Get the standard deviation of errors.
3442
+ * @returns {number}
3443
+ */
3444
+ stdDev() {
3445
+ const ret = wasm.jsmodeldiagnostics_jarqueBeraStatistic(this.__wbg_ptr);
3446
+ return ret;
3447
+ }
3448
+ }
3449
+ if (Symbol.dispose) JsNormalResult.prototype[Symbol.dispose] = JsNormalResult.prototype.free;
3450
+
3451
+ /**
3452
+ * Declarative pipeline builder for composing forecasting workflows.
3453
+ *
3454
+ * Chain configuration methods and call `build()` to produce a pipeline,
3455
+ * then `execute()` to run it.
3456
+ *
3457
+ * ```js
3458
+ * const result = new JsPipelineBuilder()
3459
+ * .profile()
3460
+ * .preprocess("auto")
3461
+ * .metric("auto")
3462
+ * .ensemble("auto")
3463
+ * .addModel("Naive")
3464
+ * .addModel("SES")
3465
+ * .withFallback()
3466
+ * .nonNegative()
3467
+ * .build()
3468
+ * .execute(ts, 12);
3469
+ * ```
3470
+ */
3471
+ export class JsPipelineBuilder {
3472
+ static __wrap(ptr) {
3473
+ ptr = ptr >>> 0;
3474
+ const obj = Object.create(JsPipelineBuilder.prototype);
3475
+ obj.__wbg_ptr = ptr;
3476
+ JsPipelineBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
3477
+ return obj;
3478
+ }
3479
+ __destroy_into_raw() {
3480
+ const ptr = this.__wbg_ptr;
3481
+ this.__wbg_ptr = 0;
3482
+ JsPipelineBuilderFinalization.unregister(this);
3483
+ return ptr;
3484
+ }
3485
+ free() {
3486
+ const ptr = this.__destroy_into_raw();
3487
+ wasm.__wbg_jspipelinebuilder_free(ptr, 0);
3488
+ }
3489
+ /**
3490
+ * Set preprocessing mode.
3491
+ *
3492
+ * @param mode - "auto", "none", or "manual"
3493
+ * @param {string} mode
3494
+ * @returns {JsPipelineBuilder}
3495
+ */
3496
+ preprocess(mode) {
3497
+ const ptr = this.__destroy_into_raw();
3498
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2683
3499
  const len0 = WASM_VECTOR_LEN;
2684
- const ret = wasm.jsnormalpredictor_predictIntervals(this.__wbg_ptr, result.__wbg_ptr, ptr0, len0);
3500
+ const ret = wasm.jspipelinebuilder_preprocess(ptr, ptr0, len0);
3501
+ return JsPipelineBuilder.__wrap(ret);
3502
+ }
3503
+ /**
3504
+ * Apply non-negative constraint to forecasts.
3505
+ * @returns {JsPipelineBuilder}
3506
+ */
3507
+ nonNegative() {
3508
+ const ptr = this.__destroy_into_raw();
3509
+ const ret = wasm.jspipelinebuilder_nonNegative(ptr);
3510
+ return JsPipelineBuilder.__wrap(ret);
3511
+ }
3512
+ /**
3513
+ * Select top-K models for evaluation.
3514
+ *
3515
+ * @param k - Number of models to select
3516
+ * @param {number} k
3517
+ * @returns {JsPipelineBuilder}
3518
+ */
3519
+ selectModels(k) {
3520
+ const ptr = this.__destroy_into_raw();
3521
+ const ret = wasm.jspipelinebuilder_selectModels(ptr, k);
3522
+ return JsPipelineBuilder.__wrap(ret);
3523
+ }
3524
+ /**
3525
+ * Enable fallback chain (Naive → SMA).
3526
+ * @returns {JsPipelineBuilder}
3527
+ */
3528
+ withFallback() {
3529
+ const ptr = this.__destroy_into_raw();
3530
+ const ret = wasm.jspipelinebuilder_withFallback(ptr);
3531
+ return JsPipelineBuilder.__wrap(ret);
3532
+ }
3533
+ /**
3534
+ * Enable cross-validation.
3535
+ *
3536
+ * @param folds - Number of CV folds
3537
+ * @param horizon - Forecast horizon for each fold
3538
+ * @param {number} folds
3539
+ * @param {number} horizon
3540
+ * @returns {JsPipelineBuilder}
3541
+ */
3542
+ crossValidate(folds, horizon) {
3543
+ const ptr = this.__destroy_into_raw();
3544
+ const ret = wasm.jspipelinebuilder_crossValidate(ptr, folds, horizon);
3545
+ return JsPipelineBuilder.__wrap(ret);
3546
+ }
3547
+ /**
3548
+ * Set the seasonal period hint.
3549
+ *
3550
+ * @param period - Seasonal period (e.g., 12 for monthly data)
3551
+ * @param {number} period
3552
+ * @returns {JsPipelineBuilder}
3553
+ */
3554
+ seasonalPeriod(period) {
3555
+ const ptr = this.__destroy_into_raw();
3556
+ const ret = wasm.jspipelinebuilder_seasonalPeriod(ptr, period);
3557
+ return JsPipelineBuilder.__wrap(ret);
3558
+ }
3559
+ /**
3560
+ * Add a seasonal model to the pipeline.
3561
+ *
3562
+ * @param name - Model name (e.g., "SeasonalNaive")
3563
+ * @param period - Seasonal period
3564
+ * @param {string} name
3565
+ * @param {number} period
3566
+ * @returns {JsPipelineBuilder}
3567
+ */
3568
+ addSeasonalModel(name, period) {
3569
+ const ptr = this.__destroy_into_raw();
3570
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3571
+ const len0 = WASM_VECTOR_LEN;
3572
+ const ret = wasm.jspipelinebuilder_addSeasonalModel(ptr, ptr0, len0, period);
3573
+ return JsPipelineBuilder.__wrap(ret);
3574
+ }
3575
+ /**
3576
+ * Create a new pipeline builder.
3577
+ */
3578
+ constructor() {
3579
+ const ret = wasm.jspipelinebuilder_new();
3580
+ this.__wbg_ptr = ret >>> 0;
3581
+ JsPipelineBuilderFinalization.register(this, this.__wbg_ptr, this);
3582
+ return this;
3583
+ }
3584
+ /**
3585
+ * Set the metric strategy for model selection.
3586
+ *
3587
+ * @param strategy - "auto", "mae", "mse", "rmse", "smape", "wape", or "mda"
3588
+ * @param {string} strategy
3589
+ * @returns {JsPipelineBuilder}
3590
+ */
3591
+ metric(strategy) {
3592
+ const ptr = this.__destroy_into_raw();
3593
+ const ptr0 = passStringToWasm0(strategy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3594
+ const len0 = WASM_VECTOR_LEN;
3595
+ const ret = wasm.jspipelinebuilder_metric(ptr, ptr0, len0);
3596
+ return JsPipelineBuilder.__wrap(ret);
3597
+ }
3598
+ /**
3599
+ * Build and execute the pipeline.
3600
+ *
3601
+ * @param series - TimeSeries to forecast
3602
+ * @param horizon - Number of steps to forecast
3603
+ * @returns JsPipelineResult with forecast, profile, and diagnostics
3604
+ * @param {TimeSeries} series
3605
+ * @param {number} horizon
3606
+ * @returns {JsPipelineResult}
3607
+ */
3608
+ execute(series, horizon) {
3609
+ const ptr = this.__destroy_into_raw();
3610
+ _assertClass(series, TimeSeries);
3611
+ const ret = wasm.jspipelinebuilder_execute(ptr, series.__wbg_ptr, horizon);
2685
3612
  if (ret[2]) {
2686
3613
  throw takeFromExternrefTable0(ret[1]);
2687
3614
  }
2688
- return JsPredictionIntervals.__wrap(ret[0]);
3615
+ return JsPipelineResult.__wrap(ret[0]);
2689
3616
  }
2690
3617
  /**
2691
- * Fit the predictor on historical forecasts and actuals.
3618
+ * Enable data profiling.
3619
+ * @returns {JsPipelineBuilder}
3620
+ */
3621
+ profile() {
3622
+ const ptr = this.__destroy_into_raw();
3623
+ const ret = wasm.jspipelinebuilder_profile(ptr);
3624
+ return JsPipelineBuilder.__wrap(ret);
3625
+ }
3626
+ /**
3627
+ * Set the ensemble mode.
2692
3628
  *
2693
- * @param forecasts - Historical point forecast values
2694
- * @param actuals - Corresponding actual observed values
2695
- * @param {Float64Array} forecasts
2696
- * @param {Float64Array} actuals
2697
- * @returns {JsNormalResult}
3629
+ * @param mode - "auto", "none", "mean", "median", or "weighted"
3630
+ * @param {string} mode
3631
+ * @returns {JsPipelineBuilder}
2698
3632
  */
2699
- fit(forecasts, actuals) {
2700
- const ptr0 = passArrayF64ToWasm0(forecasts, wasm.__wbindgen_malloc);
3633
+ ensemble(mode) {
3634
+ const ptr = this.__destroy_into_raw();
3635
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2701
3636
  const len0 = WASM_VECTOR_LEN;
2702
- const ptr1 = passArrayF64ToWasm0(actuals, wasm.__wbindgen_malloc);
2703
- const len1 = WASM_VECTOR_LEN;
2704
- const ret = wasm.jsnormalpredictor_fit(this.__wbg_ptr, ptr0, len0, ptr1, len1);
3637
+ const ret = wasm.jspipelinebuilder_ensemble(ptr, ptr0, len0);
3638
+ return JsPipelineBuilder.__wrap(ret);
3639
+ }
3640
+ /**
3641
+ * Add a built-in model to the pipeline.
3642
+ *
3643
+ * Supported models: "Naive", "SES", "SMA", "SMA5", "SMA10"
3644
+ *
3645
+ * @param name - Model name
3646
+ * @param {string} name
3647
+ * @returns {JsPipelineBuilder}
3648
+ */
3649
+ addModel(name) {
3650
+ const ptr = this.__destroy_into_raw();
3651
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3652
+ const len0 = WASM_VECTOR_LEN;
3653
+ const ret = wasm.jspipelinebuilder_addModel(ptr, ptr0, len0);
3654
+ return JsPipelineBuilder.__wrap(ret);
3655
+ }
3656
+ }
3657
+ if (Symbol.dispose) JsPipelineBuilder.prototype[Symbol.dispose] = JsPipelineBuilder.prototype.free;
3658
+
3659
+ /**
3660
+ * Structured multi-section pipeline report.
3661
+ *
3662
+ * Contains summary, data profile, preprocessing, model selection,
3663
+ * ensemble, forecast, horizon analysis, decision log, and execution metadata.
3664
+ */
3665
+ export class JsPipelineReport {
3666
+ static __wrap(ptr) {
3667
+ ptr = ptr >>> 0;
3668
+ const obj = Object.create(JsPipelineReport.prototype);
3669
+ obj.__wbg_ptr = ptr;
3670
+ JsPipelineReportFinalization.register(obj, obj.__wbg_ptr, obj);
3671
+ return obj;
3672
+ }
3673
+ __destroy_into_raw() {
3674
+ const ptr = this.__wbg_ptr;
3675
+ this.__wbg_ptr = 0;
3676
+ JsPipelineReportFinalization.unregister(this);
3677
+ return ptr;
3678
+ }
3679
+ free() {
3680
+ const ptr = this.__destroy_into_raw();
3681
+ wasm.__wbg_jspipelinereport_free(ptr, 0);
3682
+ }
3683
+ /**
3684
+ * Get the full report as formatted text.
3685
+ * @returns {string}
3686
+ */
3687
+ toString() {
3688
+ let deferred1_0;
3689
+ let deferred1_1;
3690
+ try {
3691
+ const ret = wasm.jspipelinereport_toString(this.__wbg_ptr);
3692
+ deferred1_0 = ret[0];
3693
+ deferred1_1 = ret[1];
3694
+ return getStringFromWasm0(ret[0], ret[1]);
3695
+ } finally {
3696
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3697
+ }
3698
+ }
3699
+ /**
3700
+ * Get the number of sections.
3701
+ * @returns {number}
3702
+ */
3703
+ get sectionCount() {
3704
+ const ret = wasm.jspipelinereport_sectionCount(this.__wbg_ptr);
3705
+ return ret >>> 0;
3706
+ }
3707
+ /**
3708
+ * Get a section heading by index.
3709
+ * @param {number} index
3710
+ * @returns {string | undefined}
3711
+ */
3712
+ sectionHeading(index) {
3713
+ const ret = wasm.jspipelinereport_sectionHeading(this.__wbg_ptr, index);
3714
+ let v1;
3715
+ if (ret[0] !== 0) {
3716
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
3717
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
3718
+ }
3719
+ return v1;
3720
+ }
3721
+ /**
3722
+ * Get the report title.
3723
+ * @returns {string}
3724
+ */
3725
+ get title() {
3726
+ let deferred1_0;
3727
+ let deferred1_1;
3728
+ try {
3729
+ const ret = wasm.jspipelinereport_title(this.__wbg_ptr);
3730
+ deferred1_0 = ret[0];
3731
+ deferred1_1 = ret[1];
3732
+ return getStringFromWasm0(ret[0], ret[1]);
3733
+ } finally {
3734
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3735
+ }
3736
+ }
3737
+ /**
3738
+ * Get the report as a JSON object.
3739
+ *
3740
+ * Returns `{ title, sections: [{ heading, content }] }`.
3741
+ * @returns {any}
3742
+ */
3743
+ toJSON() {
3744
+ const ret = wasm.jspipelinereport_toJSON(this.__wbg_ptr);
3745
+ if (ret[2]) {
3746
+ throw takeFromExternrefTable0(ret[1]);
3747
+ }
3748
+ return takeFromExternrefTable0(ret[0]);
3749
+ }
3750
+ }
3751
+ if (Symbol.dispose) JsPipelineReport.prototype[Symbol.dispose] = JsPipelineReport.prototype.free;
3752
+
3753
+ /**
3754
+ * Result of executing a forecasting pipeline.
3755
+ *
3756
+ * Contains the forecast, selected model name, data profile, decision log,
3757
+ * preprocessing info, ensemble weights, and metric scores.
3758
+ */
3759
+ export class JsPipelineResult {
3760
+ static __wrap(ptr) {
3761
+ ptr = ptr >>> 0;
3762
+ const obj = Object.create(JsPipelineResult.prototype);
3763
+ obj.__wbg_ptr = ptr;
3764
+ JsPipelineResultFinalization.register(obj, obj.__wbg_ptr, obj);
3765
+ return obj;
3766
+ }
3767
+ __destroy_into_raw() {
3768
+ const ptr = this.__wbg_ptr;
3769
+ this.__wbg_ptr = 0;
3770
+ JsPipelineResultFinalization.unregister(this);
3771
+ return ptr;
3772
+ }
3773
+ free() {
3774
+ const ptr = this.__destroy_into_raw();
3775
+ wasm.__wbg_jspipelineresult_free(ptr, 0);
3776
+ }
3777
+ /**
3778
+ * Get the name of the selected model.
3779
+ * @returns {string}
3780
+ */
3781
+ get modelName() {
3782
+ let deferred1_0;
3783
+ let deferred1_1;
3784
+ try {
3785
+ const ret = wasm.jspipelineresult_modelName(this.__wbg_ptr);
3786
+ deferred1_0 = ret[0];
3787
+ deferred1_1 = ret[1];
3788
+ return getStringFromWasm0(ret[0], ret[1]);
3789
+ } finally {
3790
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3791
+ }
3792
+ }
3793
+ /**
3794
+ * Get the decision log as a formatted string.
3795
+ * @returns {string}
3796
+ */
3797
+ get decisionLog() {
3798
+ let deferred1_0;
3799
+ let deferred1_1;
3800
+ try {
3801
+ const ret = wasm.jspipelineresult_decisionLog(this.__wbg_ptr);
3802
+ deferred1_0 = ret[0];
3803
+ deferred1_1 = ret[1];
3804
+ return getStringFromWasm0(ret[0], ret[1]);
3805
+ } finally {
3806
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3807
+ }
3808
+ }
3809
+ /**
3810
+ * Get a human-readable summary of the result.
3811
+ * @returns {string}
3812
+ */
3813
+ toString() {
3814
+ let deferred1_0;
3815
+ let deferred1_1;
3816
+ try {
3817
+ const ret = wasm.jspipelineresult_toString(this.__wbg_ptr);
3818
+ deferred1_0 = ret[0];
3819
+ deferred1_1 = ret[1];
3820
+ return getStringFromWasm0(ret[0], ret[1]);
3821
+ } finally {
3822
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3823
+ }
3824
+ }
3825
+ /**
3826
+ * Get metric scores as JSON (undefined if not computed).
3827
+ * @returns {any}
3828
+ */
3829
+ get metricScores() {
3830
+ const ret = wasm.jspipelineresult_metricScores(this.__wbg_ptr);
3831
+ if (ret[2]) {
3832
+ throw takeFromExternrefTable0(ret[1]);
3833
+ }
3834
+ return takeFromExternrefTable0(ret[0]);
3835
+ }
3836
+ /**
3837
+ * Get quality floor result (undefined if not computed).
3838
+ * @returns {string | undefined}
3839
+ */
3840
+ get qualityFloor() {
3841
+ const ret = wasm.jspipelineresult_qualityFloor(this.__wbg_ptr);
3842
+ let v1;
3843
+ if (ret[0] !== 0) {
3844
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
3845
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
3846
+ }
3847
+ return v1;
3848
+ }
3849
+ /**
3850
+ * Get the number of decisions in the log.
3851
+ * @returns {number}
3852
+ */
3853
+ get decisionCount() {
3854
+ const ret = wasm.jspipelineresult_decisionCount(this.__wbg_ptr);
3855
+ return ret >>> 0;
3856
+ }
3857
+ /**
3858
+ * Get preprocessing info (undefined if not applied).
3859
+ * @returns {any}
3860
+ */
3861
+ get preprocessInfo() {
3862
+ const ret = wasm.jspipelineresult_preprocessInfo(this.__wbg_ptr);
3863
+ if (ret[2]) {
3864
+ throw takeFromExternrefTable0(ret[1]);
3865
+ }
3866
+ return takeFromExternrefTable0(ret[0]);
3867
+ }
3868
+ /**
3869
+ * Get ensemble weights as JSON (undefined if not an ensemble).
3870
+ * @returns {any}
3871
+ */
3872
+ get ensembleWeights() {
3873
+ const ret = wasm.jspipelineresult_ensembleWeights(this.__wbg_ptr);
3874
+ if (ret[2]) {
3875
+ throw takeFromExternrefTable0(ret[1]);
3876
+ }
3877
+ return takeFromExternrefTable0(ret[0]);
3878
+ }
3879
+ /**
3880
+ * Get model confidence set (undefined if not computed).
3881
+ * @returns {any}
3882
+ */
3883
+ get modelConfidenceSet() {
3884
+ const ret = wasm.jspipelineresult_modelConfidenceSet(this.__wbg_ptr);
2705
3885
  if (ret[2]) {
2706
3886
  throw takeFromExternrefTable0(ret[1]);
2707
3887
  }
2708
- return JsNormalResult.__wrap(ret[0]);
3888
+ return takeFromExternrefTable0(ret[0]);
2709
3889
  }
2710
3890
  /**
2711
- * Create a new normal predictor.
2712
- *
2713
- * @param quantiles - Sorted quantile levels in (0,1), e.g. [0.1, 0.5, 0.9]
2714
- * @param {Float64Array} quantiles
3891
+ * Get selection confidence (undefined if not computed).
3892
+ * @returns {string | undefined}
2715
3893
  */
2716
- constructor(quantiles) {
2717
- const ptr0 = passArrayF64ToWasm0(quantiles, wasm.__wbindgen_malloc);
2718
- const len0 = WASM_VECTOR_LEN;
2719
- const ret = wasm.jsnormalpredictor_new(ptr0, len0);
2720
- this.__wbg_ptr = ret >>> 0;
2721
- JsNormalPredictorFinalization.register(this, this.__wbg_ptr, this);
2722
- return this;
2723
- }
2724
- }
2725
- if (Symbol.dispose) JsNormalPredictor.prototype[Symbol.dispose] = JsNormalPredictor.prototype.free;
2726
-
2727
- /**
2728
- * Normal prediction result — stores Gaussian fit parameters.
2729
- */
2730
- export class JsNormalResult {
2731
- static __wrap(ptr) {
2732
- ptr = ptr >>> 0;
2733
- const obj = Object.create(JsNormalResult.prototype);
2734
- obj.__wbg_ptr = ptr;
2735
- JsNormalResultFinalization.register(obj, obj.__wbg_ptr, obj);
2736
- return obj;
2737
- }
2738
- __destroy_into_raw() {
2739
- const ptr = this.__wbg_ptr;
2740
- this.__wbg_ptr = 0;
2741
- JsNormalResultFinalization.unregister(this);
2742
- return ptr;
3894
+ get selectionConfidence() {
3895
+ const ret = wasm.jspipelineresult_selectionConfidence(this.__wbg_ptr);
3896
+ let v1;
3897
+ if (ret[0] !== 0) {
3898
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
3899
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
3900
+ }
3901
+ return v1;
2743
3902
  }
2744
- free() {
2745
- const ptr = this.__destroy_into_raw();
2746
- wasm.__wbg_jsnormalresult_free(ptr, 0);
3903
+ /**
3904
+ * Generate a full structured report.
3905
+ * @returns {JsPipelineReport}
3906
+ */
3907
+ report() {
3908
+ const ret = wasm.jspipelineresult_report(this.__wbg_ptr);
3909
+ return JsPipelineReport.__wrap(ret);
2747
3910
  }
2748
3911
  /**
2749
- * Get the mean error (bias).
2750
- * @returns {number}
3912
+ * Get the data profile (undefined if profiling was not enabled).
3913
+ * @returns {JsDataProfile | undefined}
2751
3914
  */
2752
- get mean() {
2753
- const ret = wasm.jsnormalresult_mean(this.__wbg_ptr);
2754
- return ret;
3915
+ get profile() {
3916
+ const ret = wasm.jspipelineresult_profile(this.__wbg_ptr);
3917
+ return ret === 0 ? undefined : JsDataProfile.__wrap(ret);
2755
3918
  }
2756
3919
  /**
2757
- * Get the standard deviation of errors.
2758
- * @returns {number}
3920
+ * Get the forecast.
3921
+ * @returns {Forecast}
2759
3922
  */
2760
- stdDev() {
2761
- const ret = wasm.jsnormalresult_stdDev(this.__wbg_ptr);
2762
- return ret;
3923
+ get forecast() {
3924
+ const ret = wasm.jspipelineresult_forecast(this.__wbg_ptr);
3925
+ return Forecast.__wrap(ret);
2763
3926
  }
2764
3927
  }
2765
- if (Symbol.dispose) JsNormalResult.prototype[Symbol.dispose] = JsNormalResult.prototype.free;
3928
+ if (Symbol.dispose) JsPipelineResult.prototype[Symbol.dispose] = JsPipelineResult.prototype.free;
2766
3929
 
2767
3930
  /**
2768
3931
  * Point forecasts — a sequence of predicted values.
@@ -2995,7 +4158,7 @@ export class JsPredictionIntervals {
2995
4158
  * @returns {number}
2996
4159
  */
2997
4160
  get coverage() {
2998
- const ret = wasm.jsnormalresult_mean(this.__wbg_ptr);
4161
+ const ret = wasm.jsmodeldiagnostics_ljungBoxPvalue(this.__wbg_ptr);
2999
4162
  return ret;
3000
4163
  }
3001
4164
  /**
@@ -3037,6 +4200,139 @@ export class JsTrainedModel {
3037
4200
  }
3038
4201
  if (Symbol.dispose) JsTrainedModel.prototype[Symbol.dispose] = JsTrainedModel.prototype.free;
3039
4202
 
4203
+ /**
4204
+ * Kalman filter forecaster for state-space models.
4205
+ *
4206
+ * Supports local level and local linear trend models out of the box.
4207
+ */
4208
+ export class KalmanForecaster {
4209
+ static __wrap(ptr) {
4210
+ ptr = ptr >>> 0;
4211
+ const obj = Object.create(KalmanForecaster.prototype);
4212
+ obj.__wbg_ptr = ptr;
4213
+ KalmanForecasterFinalization.register(obj, obj.__wbg_ptr, obj);
4214
+ return obj;
4215
+ }
4216
+ __destroy_into_raw() {
4217
+ const ptr = this.__wbg_ptr;
4218
+ this.__wbg_ptr = 0;
4219
+ KalmanForecasterFinalization.unregister(this);
4220
+ return ptr;
4221
+ }
4222
+ free() {
4223
+ const ptr = this.__destroy_into_raw();
4224
+ wasm.__wbg_kalmanforecaster_free(ptr, 0);
4225
+ }
4226
+ /**
4227
+ * Create a local level (random walk plus noise) model.
4228
+ *
4229
+ * @param obs_noise - Observation noise variance
4230
+ * @param state_noise - State (level) noise variance
4231
+ * @param {number} obs_noise
4232
+ * @param {number} state_noise
4233
+ * @returns {KalmanForecaster}
4234
+ */
4235
+ static localLevel(obs_noise, state_noise) {
4236
+ const ret = wasm.kalmanforecaster_localLevel(obs_noise, state_noise);
4237
+ return KalmanForecaster.__wrap(ret);
4238
+ }
4239
+ /**
4240
+ * Create a local linear trend model.
4241
+ *
4242
+ * @param obs_noise - Observation noise variance
4243
+ * @param level_noise - Level noise variance
4244
+ * @param trend_noise - Trend noise variance
4245
+ * @param {number} obs_noise
4246
+ * @param {number} level_noise
4247
+ * @param {number} trend_noise
4248
+ * @returns {KalmanForecaster}
4249
+ */
4250
+ static localLinearTrend(obs_noise, level_noise, trend_noise) {
4251
+ const ret = wasm.kalmanforecaster_localLinearTrend(obs_noise, level_noise, trend_noise);
4252
+ return KalmanForecaster.__wrap(ret);
4253
+ }
4254
+ /**
4255
+ * Predict with prediction intervals.
4256
+ *
4257
+ * @param horizon - Number of steps to forecast
4258
+ * @param level - Confidence level (e.g., 0.95 for 95% intervals)
4259
+ * @returns Forecast with predictions and intervals
4260
+ * @param {number} horizon
4261
+ * @param {number} level
4262
+ * @returns {Forecast}
4263
+ */
4264
+ predictWithIntervals(horizon, level) {
4265
+ const ret = wasm.kalmanforecaster_predictWithIntervals(this.__wbg_ptr, horizon, level);
4266
+ if (ret[2]) {
4267
+ throw takeFromExternrefTable0(ret[1]);
4268
+ }
4269
+ return Forecast.__wrap(ret[0]);
4270
+ }
4271
+ /**
4272
+ * Fit the Kalman filter to a time series.
4273
+ *
4274
+ * @param series - TimeSeries to fit
4275
+ * @param {TimeSeries} series
4276
+ */
4277
+ fit(series) {
4278
+ _assertClass(series, TimeSeries);
4279
+ const ret = wasm.kalmanforecaster_fit(this.__wbg_ptr, series.__wbg_ptr);
4280
+ if (ret[1]) {
4281
+ throw takeFromExternrefTable0(ret[0]);
4282
+ }
4283
+ }
4284
+ /**
4285
+ * Get the model name.
4286
+ * @returns {string}
4287
+ */
4288
+ get name() {
4289
+ let deferred1_0;
4290
+ let deferred1_1;
4291
+ try {
4292
+ const ret = wasm.kalmanforecaster_name(this.__wbg_ptr);
4293
+ deferred1_0 = ret[0];
4294
+ deferred1_1 = ret[1];
4295
+ return getStringFromWasm0(ret[0], ret[1]);
4296
+ } finally {
4297
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
4298
+ }
4299
+ }
4300
+ /**
4301
+ * Apply the Kalman smoother (RTS smoother) and return smoothed observations.
4302
+ *
4303
+ * @param series - TimeSeries to smooth
4304
+ * @returns Array of smoothed observation values
4305
+ * @param {TimeSeries} series
4306
+ * @returns {Float64Array}
4307
+ */
4308
+ smooth(series) {
4309
+ _assertClass(series, TimeSeries);
4310
+ const ret = wasm.kalmanforecaster_smooth(this.__wbg_ptr, series.__wbg_ptr);
4311
+ if (ret[3]) {
4312
+ throw takeFromExternrefTable0(ret[2]);
4313
+ }
4314
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4315
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4316
+ return v1;
4317
+ }
4318
+ /**
4319
+ * Predict future values.
4320
+ *
4321
+ * @param horizon - Number of steps to forecast
4322
+ * @returns Forecast with point predictions
4323
+ * @param {number} horizon
4324
+ * @returns {Forecast}
4325
+ */
4326
+ predict(horizon) {
4327
+ const ret = wasm.kalmanforecaster_predict(this.__wbg_ptr, horizon);
4328
+ if (ret[2]) {
4329
+ throw takeFromExternrefTable0(ret[1]);
4330
+ }
4331
+ return Forecast.__wrap(ret[0]);
4332
+ }
4333
+ }
4334
+ if (Symbol.dispose) KalmanForecaster.prototype[Symbol.dispose] = KalmanForecaster.prototype.free;
4335
+
3040
4336
  /**
3041
4337
  * MFLES - Multiple Frequency Locally Estimated Scatterplot Smoothing.
3042
4338
  */
@@ -4319,6 +5615,108 @@ export class TimeSeries {
4319
5615
  }
4320
5616
  if (Symbol.dispose) TimeSeries.prototype[Symbol.dispose] = TimeSeries.prototype.free;
4321
5617
 
5618
+ /**
5619
+ * Vector Autoregression forecaster for multivariate time series.
5620
+ *
5621
+ * Models multiple time series jointly where each variable at time t is a
5622
+ * linear function of the p most recent lags of all variables.
5623
+ */
5624
+ export class VARForecaster {
5625
+ __destroy_into_raw() {
5626
+ const ptr = this.__wbg_ptr;
5627
+ this.__wbg_ptr = 0;
5628
+ VARForecasterFinalization.unregister(this);
5629
+ return ptr;
5630
+ }
5631
+ free() {
5632
+ const ptr = this.__destroy_into_raw();
5633
+ wasm.__wbg_varforecaster_free(ptr, 0);
5634
+ }
5635
+ /**
5636
+ * Fit the VAR model to multivariate time series data.
5637
+ *
5638
+ * @param data - Array of Float64Arrays, one per variable. All must have the same length.
5639
+ * @param {Array<any>} data
5640
+ */
5641
+ fitMultivariate(data) {
5642
+ const ret = wasm.varforecaster_fitMultivariate(this.__wbg_ptr, data);
5643
+ if (ret[1]) {
5644
+ throw takeFromExternrefTable0(ret[0]);
5645
+ }
5646
+ }
5647
+ /**
5648
+ * Predict future values for all variables.
5649
+ *
5650
+ * @param horizon - Number of steps to forecast
5651
+ * @returns Array of Float64Arrays, one per variable
5652
+ * @param {number} horizon
5653
+ * @returns {Array<any>}
5654
+ */
5655
+ predictMultivariate(horizon) {
5656
+ const ret = wasm.varforecaster_predictMultivariate(this.__wbg_ptr, horizon);
5657
+ if (ret[2]) {
5658
+ throw takeFromExternrefTable0(ret[1]);
5659
+ }
5660
+ return takeFromExternrefTable0(ret[0]);
5661
+ }
5662
+ /**
5663
+ * Perform a Granger causality test.
5664
+ *
5665
+ * Tests whether variable `cause` Granger-causes variable `effect`.
5666
+ *
5667
+ * @param cause - Index of the potentially causal variable (0-based)
5668
+ * @param effect - Index of the effect variable (0-based)
5669
+ * @returns F-statistic. Higher values indicate stronger evidence of causality.
5670
+ * @param {number} cause
5671
+ * @param {number} effect
5672
+ * @returns {number}
5673
+ */
5674
+ grangerCausalityTest(cause, effect) {
5675
+ const ret = wasm.varforecaster_grangerCausalityTest(this.__wbg_ptr, cause, effect);
5676
+ if (ret[2]) {
5677
+ throw takeFromExternrefTable0(ret[1]);
5678
+ }
5679
+ return ret[0];
5680
+ }
5681
+ /**
5682
+ * Create a new VAR forecaster with the given lag order.
5683
+ *
5684
+ * @param order - Number of lags (p). Must be at least 1.
5685
+ * @param {number} order
5686
+ */
5687
+ constructor(order) {
5688
+ const ret = wasm.varforecaster_new(order);
5689
+ this.__wbg_ptr = ret >>> 0;
5690
+ VARForecasterFinalization.register(this, this.__wbg_ptr, this);
5691
+ return this;
5692
+ }
5693
+ /**
5694
+ * Get the model name.
5695
+ * @returns {string}
5696
+ */
5697
+ get name() {
5698
+ let deferred1_0;
5699
+ let deferred1_1;
5700
+ try {
5701
+ const ret = wasm.varforecaster_name(this.__wbg_ptr);
5702
+ deferred1_0 = ret[0];
5703
+ deferred1_1 = ret[1];
5704
+ return getStringFromWasm0(ret[0], ret[1]);
5705
+ } finally {
5706
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
5707
+ }
5708
+ }
5709
+ /**
5710
+ * Get the lag order.
5711
+ * @returns {number}
5712
+ */
5713
+ get order() {
5714
+ const ret = wasm.varforecaster_order(this.__wbg_ptr);
5715
+ return ret >>> 0;
5716
+ }
5717
+ }
5718
+ if (Symbol.dispose) VARForecaster.prototype[Symbol.dispose] = VARForecaster.prototype.free;
5719
+
4322
5720
  /**
4323
5721
  * Window Average forecaster - uses the last N observations.
4324
5722
  */
@@ -4640,6 +6038,27 @@ export function durbinWatson(residuals) {
4640
6038
  return takeFromExternrefTable0(ret[0]);
4641
6039
  }
4642
6040
 
6041
+ /**
6042
+ * Generate a human-readable explanation of a pipeline result.
6043
+ *
6044
+ * @param result - A JsPipelineResult to explain
6045
+ * @param verbosity - "brief", "normal", or "detailed"
6046
+ * @returns Object with `summary` and `sections`
6047
+ * @param {JsPipelineResult} result
6048
+ * @param {string} verbosity
6049
+ * @returns {any}
6050
+ */
6051
+ export function explainResult(result, verbosity) {
6052
+ _assertClass(result, JsPipelineResult);
6053
+ const ptr0 = passStringToWasm0(verbosity, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
6054
+ const len0 = WASM_VECTOR_LEN;
6055
+ const ret = wasm.explainResult(result.__wbg_ptr, ptr0, len0);
6056
+ if (ret[2]) {
6057
+ throw takeFromExternrefTable0(ret[1]);
6058
+ }
6059
+ return takeFromExternrefTable0(ret[0]);
6060
+ }
6061
+
4643
6062
  /**
4644
6063
  * Initialize the WASM module.
4645
6064
  *
@@ -4822,6 +6241,28 @@ export function sampleEntropy(values, m, r) {
4822
6241
  return ret;
4823
6242
  }
4824
6243
 
6244
+ /**
6245
+ * Recommend models based on data profile characteristics.
6246
+ *
6247
+ * Returns an object with `recommended` (model names) and `reasoning` (explanations).
6248
+ *
6249
+ * @param profile - A JsDataProfile from profiling
6250
+ * @param availableModels - Optional array of model names to filter by
6251
+ * @param {JsDataProfile} profile
6252
+ * @param {string[] | null} [available_models]
6253
+ * @returns {any}
6254
+ */
6255
+ export function selectModels(profile, available_models) {
6256
+ _assertClass(profile, JsDataProfile);
6257
+ var ptr0 = isLikeNone(available_models) ? 0 : passArrayJsValueToWasm0(available_models, wasm.__wbindgen_malloc);
6258
+ var len0 = WASM_VECTOR_LEN;
6259
+ const ret = wasm.selectModels(profile.__wbg_ptr, ptr0, len0);
6260
+ if (ret[2]) {
6261
+ throw takeFromExternrefTable0(ret[1]);
6262
+ }
6263
+ return takeFromExternrefTable0(ret[0]);
6264
+ }
6265
+
4825
6266
  /**
4826
6267
  * Compute the skewness (third standardized moment) of a time series.
4827
6268
  *
@@ -4990,10 +6431,32 @@ function __wbg_get_imports() {
4990
6431
  const ret = arg0.getTime();
4991
6432
  return ret;
4992
6433
  };
6434
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
6435
+ const ret = arg0[arg1 >>> 0];
6436
+ return ret;
6437
+ };
6438
+ imports.wbg.__wbg_instanceof_Float64Array_9fefccd7bfa2fefe = function(arg0) {
6439
+ let result;
6440
+ try {
6441
+ result = arg0 instanceof Float64Array;
6442
+ } catch (_) {
6443
+ result = false;
6444
+ }
6445
+ const ret = result;
6446
+ return ret;
6447
+ };
4993
6448
  imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
4994
6449
  const ret = arg0.length;
4995
6450
  return ret;
4996
6451
  };
6452
+ imports.wbg.__wbg_length_406f6daaaa453057 = function(arg0) {
6453
+ const ret = arg0.length;
6454
+ return ret;
6455
+ };
6456
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
6457
+ const ret = arg0.length;
6458
+ return ret;
6459
+ };
4997
6460
  imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
4998
6461
  const ret = arg0.msCrypto;
4999
6462
  return ret;
@@ -5014,6 +6477,14 @@ function __wbg_get_imports() {
5014
6477
  const ret = new Function(getStringFromWasm0(arg0, arg1));
5015
6478
  return ret;
5016
6479
  };
6480
+ imports.wbg.__wbg_new_with_length_12c6de4fac33117a = function(arg0) {
6481
+ const ret = new Array(arg0 >>> 0);
6482
+ return ret;
6483
+ };
6484
+ imports.wbg.__wbg_new_with_length_806b9e5b8290af7c = function(arg0) {
6485
+ const ret = new Float64Array(arg0 >>> 0);
6486
+ return ret;
6487
+ };
5017
6488
  imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
5018
6489
  const ret = new Uint8Array(arg0 >>> 0);
5019
6490
  return ret;
@@ -5026,6 +6497,9 @@ function __wbg_get_imports() {
5026
6497
  const ret = arg0.process;
5027
6498
  return ret;
5028
6499
  };
6500
+ imports.wbg.__wbg_prototypesetcall_d3c4edbb4ef96ca1 = function(arg0, arg1, arg2) {
6501
+ Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
6502
+ };
5029
6503
  imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
5030
6504
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
5031
6505
  };
@@ -5036,6 +6510,9 @@ function __wbg_get_imports() {
5036
6510
  const ret = module.require;
5037
6511
  return ret;
5038
6512
  }, arguments) };
6513
+ imports.wbg.__wbg_set_22933af9286a43df = function(arg0, arg1, arg2) {
6514
+ arg0.set(getArrayF64FromWasm0(arg1, arg2));
6515
+ };
5039
6516
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
5040
6517
  arg0[arg1] = arg2;
5041
6518
  };