arima icon indicating copy to clipboard operation
arima copied to clipboard

Issue with prediction. Model is not creating from beginning. It retrain the existing one.

Open ghost opened this issue 3 years ago • 1 comments

How to reproduce ? `const ARIMA = require('arima')

for(let i of Array(50)) { const ts = [81, 123, 175, 174, 130, 134, 150, 211, 240, 222, 159, 219, 109, 128, 155, 149, 98, 116, 93, 136, 201, 194, 195, 308];

const arima = new ARIMA({
    "verbose": false,
    "p": 1,
    "d": 1,
    "q": 1,
    "method": 0,
    "optimizer": 6,
    "P": 2,
    "D": 1,
    "Q": 2,
    "s": 12
}).train(ts)
const [pred, errors] = arima.predict(24)
console.log(pred);

}`

Like you see i create the new model each time. And the data set does not change. i got two times correct result :

[
  216.08903590342277,  239.6406144569421,
  267.89498883554035,  262.1911453749664,
   211.3076749524534, 229.21478456387018,
  206.51948092058473,  249.6593046446444,
   314.3816613182281,  307.2968154245733,
   307.8028675181308,  420.3938562984081,
   328.3435169837437, 351.86064907178456,
   380.1060861812425,  374.4001057582379,
   323.5159444064528, 341.42335397740834,
   318.7268602179344, 361.86614087453273,
   426.5895682189373,  419.5050495675654,
  420.01300790199423,  532.6055751648078
]

After third time i got the wrong one

[
  196.74715368116387,  204.3729118507515,
   218.9898465482616,  210.5132908879587,
  156.04610733420577, 180.98047432406986,
   138.6633091404668, 172.74769444027885,
   255.5789238451663, 254.02735473863788,
   286.7273390737301,  425.9774642880317,
  314.19852555182104, 313.04656994897863,
  318.11449634155883, 307.72816230422285,
  250.58728673912913,  280.8690377039543,
  223.65558859109467, 250.86476592356135,
   347.4464112630595, 350.09635814212993,
    407.241525988272,  566.7353441379937
]

And fourth is completly broken:

[
  NaN, NaN, NaN, NaN, NaN,
  NaN, NaN, NaN, NaN, NaN,
  NaN, NaN, NaN, NaN, NaN,
  NaN, NaN, NaN, NaN, NaN,
  NaN, NaN, NaN, NaN
]

It's critical issue in my opinion. I created the arima web worker. So for each data set i create new worker. and I terminate old one. I removed the console.logs too. But for the optimization to not create and compile arima for each data set it should be resolved.

ghost avatar Dec 03 '21 14:12 ghost

Facing same issue.

If retraining is the default approach then there should be a option to clear up training model,

may be ts.cleanup() or parameter option to clearnOnPredict or something similar.

sasikanth513 avatar Feb 05 '23 03:02 sasikanth513