@xyo-network/diviner-forecasting-method-arima 2.84.2 → 2.84.3
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/dist/browser/index.cjs +1 -1
- package/dist/node/index.cjs +102 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.js +4 -46
- package/dist/node/index.js.map +1 -1
- package/package.json +12 -11
- package/dist/node/index.mjs +0 -60
- package/dist/node/index.mjs.map +0 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@ __export(src_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
44
|
|
|
45
45
|
// src/arima/configurable/configurableArima.ts
|
|
46
|
-
var import_arima = __toESM(require("arima"));
|
|
46
|
+
var import_arima = __toESM(require("arima"), 1);
|
|
47
47
|
var commonOpts = {
|
|
48
48
|
verbose: false
|
|
49
49
|
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
arimaForecastingMethod: () => arimaForecastingMethod,
|
|
35
|
+
arimaForecastingName: () => arimaForecastingName,
|
|
36
|
+
arimaOpts: () => arimaOpts,
|
|
37
|
+
commonOpts: () => commonOpts,
|
|
38
|
+
configurableArima: () => configurableArima,
|
|
39
|
+
seasonalArimaForecastingMethod: () => seasonalArimaForecastingMethod,
|
|
40
|
+
seasonalArimaForecastingName: () => seasonalArimaForecastingName,
|
|
41
|
+
seasonalArimaOpts: () => seasonalArimaOpts
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
|
|
45
|
+
// src/arima/configurable/configurableArima.ts
|
|
46
|
+
var import_arima = __toESM(require("arima"), 1);
|
|
47
|
+
var commonOpts = {
|
|
48
|
+
verbose: false
|
|
49
|
+
};
|
|
50
|
+
var configurableArima = /* @__PURE__ */ __name((opts = commonOpts, predictionSteps = 10) => {
|
|
51
|
+
return (payloads, transformer) => {
|
|
52
|
+
if (payloads.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
const values = payloads.map(transformer);
|
|
55
|
+
const model = new import_arima.default({
|
|
56
|
+
...commonOpts,
|
|
57
|
+
...opts
|
|
58
|
+
}).train(values);
|
|
59
|
+
const predictions = model.predict(predictionSteps);
|
|
60
|
+
return predictions[0].map((value, index) => {
|
|
61
|
+
const error = predictions[1][index];
|
|
62
|
+
return {
|
|
63
|
+
error,
|
|
64
|
+
value
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
}, "configurableArima");
|
|
69
|
+
|
|
70
|
+
// src/arima/configured/arima.ts
|
|
71
|
+
var arimaOpts = {
|
|
72
|
+
d: 1,
|
|
73
|
+
p: 2,
|
|
74
|
+
q: 2
|
|
75
|
+
};
|
|
76
|
+
var arimaForecastingName = "arimaForecasting";
|
|
77
|
+
var arimaForecastingMethod = configurableArima(arimaOpts);
|
|
78
|
+
|
|
79
|
+
// src/arima/configured/seasonalArima.ts
|
|
80
|
+
var seasonalArimaOpts = {
|
|
81
|
+
D: 0,
|
|
82
|
+
P: 1,
|
|
83
|
+
Q: 1,
|
|
84
|
+
d: 1,
|
|
85
|
+
p: 2,
|
|
86
|
+
q: 2,
|
|
87
|
+
s: 12
|
|
88
|
+
};
|
|
89
|
+
var seasonalArimaForecastingName = "seasonalArimaForecasting";
|
|
90
|
+
var seasonalArimaForecastingMethod = configurableArima(seasonalArimaOpts);
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
arimaForecastingMethod,
|
|
94
|
+
arimaForecastingName,
|
|
95
|
+
arimaOpts,
|
|
96
|
+
commonOpts,
|
|
97
|
+
configurableArima,
|
|
98
|
+
seasonalArimaForecastingMethod,
|
|
99
|
+
seasonalArimaForecastingName,
|
|
100
|
+
seasonalArimaOpts
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/arima/configurable/configurableArima.ts","../../src/arima/configured/arima.ts","../../src/arima/configured/seasonalArima.ts"],"sourcesContent":["export * from './arima'\n","import { Forecast, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport ARIMA, { ARIMAOptions } from 'arima'\n\nexport const commonOpts: ARIMAOptions = { verbose: false }\n\nexport type PredictionPayload = Payload<{ error?: number; value: number }>\n\nexport const configurableArima = (opts: ARIMAOptions = commonOpts, predictionSteps = 10): ForecastingMethod => {\n return (payloads: Payload[], transformer: PayloadValueTransformer): Forecast[] => {\n // If there's no input, there's no prediction\n if (payloads.length === 0) return []\n // Transform all the values\n const values = payloads.map(transformer)\n // Train a model on the training set\n const model = new ARIMA({ ...commonOpts, ...opts }).train(values)\n // Use the trained model to predict the next N values\n const predictions = model.predict(predictionSteps)\n // Convert the predictions into payloads\n return predictions[0].map((value, index) => {\n const error = predictions[1][index]\n return { error, value }\n })\n }\n}\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const arimaOpts: ARIMAOptions = { d: 1, p: 2, q: 2 }\n\nexport const arimaForecastingName = 'arimaForecasting'\n\nexport const arimaForecastingMethod: ForecastingMethod = configurableArima(arimaOpts)\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const seasonalArimaOpts: ARIMAOptions = { D: 0, P: 1, Q: 1, d: 1, p: 2, q: 2, s: 12 }\n\nexport const seasonalArimaForecastingName = 'seasonalArimaForecasting'\n\nexport const seasonalArimaForecastingMethod: ForecastingMethod = configurableArima(seasonalArimaOpts)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;ACEA,mBAAoC;AAE7B,IAAMA,aAA2B;EAAEC,SAAS;AAAM;AAIlD,IAAMC,oBAAoB,wBAACC,OAAqBH,YAAYI,kBAAkB,OAAE;AACrF,SAAO,CAACC,UAAqBC,gBAAAA;AAE3B,QAAID,SAASE,WAAW;AAAG,aAAO,CAAA;AAElC,UAAMC,SAASH,SAASI,IAAIH,WAAAA;AAE5B,UAAMI,QAAQ,IAAIC,aAAAA,QAAM;MAAE,GAAGX;MAAY,GAAGG;IAAK,CAAA,EAAGS,MAAMJ,MAAAA;AAE1D,UAAMK,cAAcH,MAAMI,QAAQV,eAAAA;AAElC,WAAOS,YAAY,CAAA,EAAGJ,IAAI,CAACM,OAAOC,UAAAA;AAChC,YAAMC,QAAQJ,YAAY,CAAA,EAAGG,KAAAA;AAC7B,aAAO;QAAEC;QAAOF;MAAM;IACxB,CAAA;EACF;AACF,GAhBiC;;;ACH1B,IAAMG,YAA0B;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAE;AAEnD,IAAMC,uBAAuB;AAE7B,IAAMC,yBAA4CC,kBAAkBN,SAAAA;;;ACJpE,IAAMO,oBAAkC;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAG;AAEpF,IAAMC,+BAA+B;AAErC,IAAMC,iCAAoDC,kBAAkBV,iBAAAA;","names":["commonOpts","verbose","configurableArima","opts","predictionSteps","payloads","transformer","length","values","map","model","ARIMA","train","predictions","predict","value","index","error","arimaOpts","d","p","q","arimaForecastingName","arimaForecastingMethod","configurableArima","seasonalArimaOpts","D","P","Q","d","p","q","s","seasonalArimaForecastingName","seasonalArimaForecastingMethod","configurableArima"]}
|
package/dist/node/index.js
CHANGED
|
@@ -1,49 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
1
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var src_exports = {};
|
|
33
|
-
__export(src_exports, {
|
|
34
|
-
arimaForecastingMethod: () => arimaForecastingMethod,
|
|
35
|
-
arimaForecastingName: () => arimaForecastingName,
|
|
36
|
-
arimaOpts: () => arimaOpts,
|
|
37
|
-
commonOpts: () => commonOpts,
|
|
38
|
-
configurableArima: () => configurableArima,
|
|
39
|
-
seasonalArimaForecastingMethod: () => seasonalArimaForecastingMethod,
|
|
40
|
-
seasonalArimaForecastingName: () => seasonalArimaForecastingName,
|
|
41
|
-
seasonalArimaOpts: () => seasonalArimaOpts
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(src_exports);
|
|
44
3
|
|
|
45
4
|
// src/arima/configurable/configurableArima.ts
|
|
46
|
-
|
|
5
|
+
import ARIMA from "arima";
|
|
47
6
|
var commonOpts = {
|
|
48
7
|
verbose: false
|
|
49
8
|
};
|
|
@@ -52,7 +11,7 @@ var configurableArima = /* @__PURE__ */ __name((opts = commonOpts, predictionSte
|
|
|
52
11
|
if (payloads.length === 0)
|
|
53
12
|
return [];
|
|
54
13
|
const values = payloads.map(transformer);
|
|
55
|
-
const model = new
|
|
14
|
+
const model = new ARIMA({
|
|
56
15
|
...commonOpts,
|
|
57
16
|
...opts
|
|
58
17
|
}).train(values);
|
|
@@ -88,8 +47,7 @@ var seasonalArimaOpts = {
|
|
|
88
47
|
};
|
|
89
48
|
var seasonalArimaForecastingName = "seasonalArimaForecasting";
|
|
90
49
|
var seasonalArimaForecastingMethod = configurableArima(seasonalArimaOpts);
|
|
91
|
-
|
|
92
|
-
0 && (module.exports = {
|
|
50
|
+
export {
|
|
93
51
|
arimaForecastingMethod,
|
|
94
52
|
arimaForecastingName,
|
|
95
53
|
arimaOpts,
|
|
@@ -98,5 +56,5 @@ var seasonalArimaForecastingMethod = configurableArima(seasonalArimaOpts);
|
|
|
98
56
|
seasonalArimaForecastingMethod,
|
|
99
57
|
seasonalArimaForecastingName,
|
|
100
58
|
seasonalArimaOpts
|
|
101
|
-
}
|
|
59
|
+
};
|
|
102
60
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/arima/configurable/configurableArima.ts","../../src/arima/configured/arima.ts","../../src/arima/configured/seasonalArima.ts"],"sourcesContent":["import { Forecast, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport ARIMA, { ARIMAOptions } from 'arima'\n\nexport const commonOpts: ARIMAOptions = { verbose: false }\n\nexport type PredictionPayload = Payload<{ error?: number; value: number }>\n\nexport const configurableArima = (opts: ARIMAOptions = commonOpts, predictionSteps = 10): ForecastingMethod => {\n return (payloads: Payload[], transformer: PayloadValueTransformer): Forecast[] => {\n // If there's no input, there's no prediction\n if (payloads.length === 0) return []\n // Transform all the values\n const values = payloads.map(transformer)\n // Train a model on the training set\n const model = new ARIMA({ ...commonOpts, ...opts }).train(values)\n // Use the trained model to predict the next N values\n const predictions = model.predict(predictionSteps)\n // Convert the predictions into payloads\n return predictions[0].map((value, index) => {\n const error = predictions[1][index]\n return { error, value }\n })\n }\n}\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const arimaOpts: ARIMAOptions = { d: 1, p: 2, q: 2 }\n\nexport const arimaForecastingName = 'arimaForecasting'\n\nexport const arimaForecastingMethod: ForecastingMethod = configurableArima(arimaOpts)\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const seasonalArimaOpts: ARIMAOptions = { D: 0, P: 1, Q: 1, d: 1, p: 2, q: 2, s: 12 }\n\nexport const seasonalArimaForecastingName = 'seasonalArimaForecasting'\n\nexport const seasonalArimaForecastingMethod: ForecastingMethod = configurableArima(seasonalArimaOpts)\n"],"mappings":";;;;AAEA,OAAOA,WAA6B;AAE7B,IAAMC,aAA2B;EAAEC,SAAS;AAAM;AAIlD,IAAMC,oBAAoB,wBAACC,OAAqBH,YAAYI,kBAAkB,OAAE;AACrF,SAAO,CAACC,UAAqBC,gBAAAA;AAE3B,QAAID,SAASE,WAAW;AAAG,aAAO,CAAA;AAElC,UAAMC,SAASH,SAASI,IAAIH,WAAAA;AAE5B,UAAMI,QAAQ,IAAIC,MAAM;MAAE,GAAGX;MAAY,GAAGG;IAAK,CAAA,EAAGS,MAAMJ,MAAAA;AAE1D,UAAMK,cAAcH,MAAMI,QAAQV,eAAAA;AAElC,WAAOS,YAAY,CAAA,EAAGJ,IAAI,CAACM,OAAOC,UAAAA;AAChC,YAAMC,QAAQJ,YAAY,CAAA,EAAGG,KAAAA;AAC7B,aAAO;QAAEC;QAAOF;MAAM;IACxB,CAAA;EACF;AACF,GAhBiC;;;ACH1B,IAAMG,YAA0B;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAE;AAEnD,IAAMC,uBAAuB;AAE7B,IAAMC,yBAA4CC,kBAAkBN,SAAAA;;;ACJpE,IAAMO,oBAAkC;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAG;AAEpF,IAAMC,+BAA+B;AAErC,IAAMC,iCAAoDC,kBAAkBV,iBAAAA;","names":["ARIMA","commonOpts","verbose","configurableArima","opts","predictionSteps","payloads","transformer","length","values","map","model","ARIMA","train","predictions","predict","value","index","error","arimaOpts","d","p","q","arimaForecastingName","arimaForecastingMethod","configurableArima","seasonalArimaOpts","D","P","Q","d","p","q","s","seasonalArimaForecastingName","seasonalArimaForecastingMethod","configurableArima"]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.84.
|
|
7
|
+
"version": "2.84.3",
|
|
8
8
|
"description": "XYO Archivist",
|
|
9
9
|
"sideeffects": false,
|
|
10
10
|
"engines": {
|
|
@@ -25,29 +25,30 @@
|
|
|
25
25
|
},
|
|
26
26
|
"node": {
|
|
27
27
|
"require": {
|
|
28
|
-
"types": "./dist/node/index.d.
|
|
29
|
-
"default": "./dist/node/index.
|
|
28
|
+
"types": "./dist/node/index.d.cts",
|
|
29
|
+
"default": "./dist/node/index.cjs"
|
|
30
30
|
},
|
|
31
31
|
"import": {
|
|
32
32
|
"types": "./dist/node/index.d.mts",
|
|
33
|
-
"default": "./dist/node/index.
|
|
33
|
+
"default": "./dist/node/index.js"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
|
-
"main": "dist/node/index.
|
|
40
|
-
"module": "dist/node/index.
|
|
39
|
+
"main": "dist/node/index.cjs",
|
|
40
|
+
"module": "dist/node/index.js",
|
|
41
41
|
"author": "Arie Trouw",
|
|
42
42
|
"license": "LGPL-3.0-only",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@xyo-network/diviner-forecasting-model": "~2.84.
|
|
45
|
-
"@xyo-network/payload-model": "~2.84.
|
|
44
|
+
"@xyo-network/diviner-forecasting-model": "~2.84.3",
|
|
45
|
+
"@xyo-network/payload-model": "~2.84.3",
|
|
46
46
|
"arima": "^0.2.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "^3.2.
|
|
50
|
-
"@xylabs/tsconfig": "^3.2.
|
|
49
|
+
"@xylabs/ts-scripts-yarn3": "^3.2.19",
|
|
50
|
+
"@xylabs/tsconfig": "^3.2.19",
|
|
51
51
|
"typescript": "^5.3.3"
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"type": "module"
|
|
53
54
|
}
|
package/dist/node/index.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/arima/configurable/configurableArima.ts
|
|
5
|
-
import ARIMA from "arima";
|
|
6
|
-
var commonOpts = {
|
|
7
|
-
verbose: false
|
|
8
|
-
};
|
|
9
|
-
var configurableArima = /* @__PURE__ */ __name((opts = commonOpts, predictionSteps = 10) => {
|
|
10
|
-
return (payloads, transformer) => {
|
|
11
|
-
if (payloads.length === 0)
|
|
12
|
-
return [];
|
|
13
|
-
const values = payloads.map(transformer);
|
|
14
|
-
const model = new ARIMA({
|
|
15
|
-
...commonOpts,
|
|
16
|
-
...opts
|
|
17
|
-
}).train(values);
|
|
18
|
-
const predictions = model.predict(predictionSteps);
|
|
19
|
-
return predictions[0].map((value, index) => {
|
|
20
|
-
const error = predictions[1][index];
|
|
21
|
-
return {
|
|
22
|
-
error,
|
|
23
|
-
value
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}, "configurableArima");
|
|
28
|
-
|
|
29
|
-
// src/arima/configured/arima.ts
|
|
30
|
-
var arimaOpts = {
|
|
31
|
-
d: 1,
|
|
32
|
-
p: 2,
|
|
33
|
-
q: 2
|
|
34
|
-
};
|
|
35
|
-
var arimaForecastingName = "arimaForecasting";
|
|
36
|
-
var arimaForecastingMethod = configurableArima(arimaOpts);
|
|
37
|
-
|
|
38
|
-
// src/arima/configured/seasonalArima.ts
|
|
39
|
-
var seasonalArimaOpts = {
|
|
40
|
-
D: 0,
|
|
41
|
-
P: 1,
|
|
42
|
-
Q: 1,
|
|
43
|
-
d: 1,
|
|
44
|
-
p: 2,
|
|
45
|
-
q: 2,
|
|
46
|
-
s: 12
|
|
47
|
-
};
|
|
48
|
-
var seasonalArimaForecastingName = "seasonalArimaForecasting";
|
|
49
|
-
var seasonalArimaForecastingMethod = configurableArima(seasonalArimaOpts);
|
|
50
|
-
export {
|
|
51
|
-
arimaForecastingMethod,
|
|
52
|
-
arimaForecastingName,
|
|
53
|
-
arimaOpts,
|
|
54
|
-
commonOpts,
|
|
55
|
-
configurableArima,
|
|
56
|
-
seasonalArimaForecastingMethod,
|
|
57
|
-
seasonalArimaForecastingName,
|
|
58
|
-
seasonalArimaOpts
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/arima/configurable/configurableArima.ts","../../src/arima/configured/arima.ts","../../src/arima/configured/seasonalArima.ts"],"sourcesContent":["import { Forecast, ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport ARIMA, { ARIMAOptions } from 'arima'\n\nexport const commonOpts: ARIMAOptions = { verbose: false }\n\nexport type PredictionPayload = Payload<{ error?: number; value: number }>\n\nexport const configurableArima = (opts: ARIMAOptions = commonOpts, predictionSteps = 10): ForecastingMethod => {\n return (payloads: Payload[], transformer: PayloadValueTransformer): Forecast[] => {\n // If there's no input, there's no prediction\n if (payloads.length === 0) return []\n // Transform all the values\n const values = payloads.map(transformer)\n // Train a model on the training set\n const model = new ARIMA({ ...commonOpts, ...opts }).train(values)\n // Use the trained model to predict the next N values\n const predictions = model.predict(predictionSteps)\n // Convert the predictions into payloads\n return predictions[0].map((value, index) => {\n const error = predictions[1][index]\n return { error, value }\n })\n }\n}\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const arimaOpts: ARIMAOptions = { d: 1, p: 2, q: 2 }\n\nexport const arimaForecastingName = 'arimaForecasting'\n\nexport const arimaForecastingMethod: ForecastingMethod = configurableArima(arimaOpts)\n","import { ForecastingMethod } from '@xyo-network/diviner-forecasting-model'\nimport { ARIMAOptions } from 'arima'\n\nimport { configurableArima } from '../configurable'\n\nexport const seasonalArimaOpts: ARIMAOptions = { D: 0, P: 1, Q: 1, d: 1, p: 2, q: 2, s: 12 }\n\nexport const seasonalArimaForecastingName = 'seasonalArimaForecasting'\n\nexport const seasonalArimaForecastingMethod: ForecastingMethod = configurableArima(seasonalArimaOpts)\n"],"mappings":";;;;AAEA,OAAOA,WAA6B;AAE7B,IAAMC,aAA2B;EAAEC,SAAS;AAAM;AAIlD,IAAMC,oBAAoB,wBAACC,OAAqBH,YAAYI,kBAAkB,OAAE;AACrF,SAAO,CAACC,UAAqBC,gBAAAA;AAE3B,QAAID,SAASE,WAAW;AAAG,aAAO,CAAA;AAElC,UAAMC,SAASH,SAASI,IAAIH,WAAAA;AAE5B,UAAMI,QAAQ,IAAIC,MAAM;MAAE,GAAGX;MAAY,GAAGG;IAAK,CAAA,EAAGS,MAAMJ,MAAAA;AAE1D,UAAMK,cAAcH,MAAMI,QAAQV,eAAAA;AAElC,WAAOS,YAAY,CAAA,EAAGJ,IAAI,CAACM,OAAOC,UAAAA;AAChC,YAAMC,QAAQJ,YAAY,CAAA,EAAGG,KAAAA;AAC7B,aAAO;QAAEC;QAAOF;MAAM;IACxB,CAAA;EACF;AACF,GAhBiC;;;ACH1B,IAAMG,YAA0B;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAE;AAEnD,IAAMC,uBAAuB;AAE7B,IAAMC,yBAA4CC,kBAAkBN,SAAAA;;;ACJpE,IAAMO,oBAAkC;EAAEC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;EAAGC,GAAG;AAAG;AAEpF,IAAMC,+BAA+B;AAErC,IAAMC,iCAAoDC,kBAAkBV,iBAAAA;","names":["ARIMA","commonOpts","verbose","configurableArima","opts","predictionSteps","payloads","transformer","length","values","map","model","ARIMA","train","predictions","predict","value","index","error","arimaOpts","d","p","q","arimaForecastingName","arimaForecastingMethod","configurableArima","seasonalArimaOpts","D","P","Q","d","p","q","s","seasonalArimaForecastingName","seasonalArimaForecastingMethod","configurableArima"]}
|