diff --git a/.gitignore b/.gitignore index f286952aa..ec0092def 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ docs/_site build dist .vscode +*.gif \ No newline at end of file diff --git a/Makefile b/Makefile index 4c2be1a0b..8152f1e6f 100644 --- a/Makefile +++ b/Makefile @@ -34,4 +34,11 @@ dist: clean python setup.py sdist bdist_wheel clean: - rm -rf dist \ No newline at end of file + rm -rf dist + +nbdev_flow: + nbdev_install_git_hooks && nbdev_build_lib \ + && nbdev_build_docs \ + && nbdev_clean_nbs --clear_all True --fname "nbs/*" \ + && nbdev_diff_nbs \ + && nbdev_test_nbs --timing diff --git a/docs/arima.html b/docs/arima.html index 753ee9b84..c48b429e0 100644 --- a/docs/arima.html +++ b/docs/arima.html @@ -59,9 +59,9 @@
-
{'ar1': 0.47051736809750594,
- 'ar2': 0.22174549894902976,
- 'ma1': -1.088591942427617}
+
{'ar1': 0.466880673428245,
+ 'ar2': 0.22506344134934328,
+ 'ma1': -1.0964437716813402}
@@ -125,11 +125,11 @@

predict_arima -
(array([448.08972925, 423.7922724 , 453.50022757, 496.68138142,
-        508.6158662 , 572.31747306, 659.85480907, 644.26321316,
-        546.57452622, 499.81156619]),
- array([11.52472983, 13.1634063 , 14.67466798, 15.63674637, 16.39162602,
-        16.98465381, 17.47757493, 17.89954747, 18.27186588, 18.60809127]))
+
(array([448.03641765, 423.6958796 , 453.37910036, 496.53844782,
+        508.4585562 , 572.14906375, 659.67853114, 644.08113724,
+        546.38826999, 499.62227626]),
+ array([11.53128398, 13.1873165 , 14.74522214, 15.74954361, 16.54939395,
+        17.18562958, 17.7205789 , 18.18296878, 18.59424176, 18.96803794]))
@@ -162,12 +162,12 @@

predict_arima -
(array([470.00979488, 440.51641849, 442.19288043, 430.30732962,
-        425.09870714, 417.37227647, 411.26942366, 404.89077868,
-        399.07483755, 393.42076235]),
- array([ 30.69910081,  51.71193144,  61.8938269 ,  71.06720305,
-         77.98073384,  83.94820591,  88.93458668,  93.25690786,
-         96.99562864, 100.27009363]))
+
(array([470.0097129 , 440.51623786, 442.19261859, 430.30698345,
+        425.09828469, 417.37177946, 411.26885683, 404.89014495,
+        399.07414049, 393.42000495]),
+ array([ 30.69910087,  51.7119296 ,  61.89382391,  71.067199  ,
+         77.98072868,  83.94819971,  88.93457943,  93.2568996 ,
+         96.9956194 , 100.27008344]))
@@ -202,11 +202,11 @@

predict_arima -
(array([441.89788144, 463.67037804, 489.91183156, 513.32967966,
-        528.76742686, 534.25615255, 530.97888695, 522.3581832 ,
-        512.68418691, 505.75238209]),
- array([25.04154419, 31.85337573, 33.32711537, 33.3424047 , 34.68174014,
-        37.33840844, 39.68800215, 40.77979968, 40.92280668, 40.99296291]))
+
(array([441.89777076, 463.6701726 , 489.91157043, 513.32941052,
+        528.76719128, 534.25597523, 530.97877135, 522.35811387,
+        512.68413676, 505.7523218 ]),
+ array([25.04154425, 31.85337615, 33.32711649, 33.34240568, 34.68173961,
+        37.33840629, 39.6879995 , 40.7797975 , 40.92280492, 40.99296076]))
@@ -240,7 +240,7 @@

predict_arima -
1020.700659230761
+
1020.8073918488345
@@ -475,17 +475,17 @@

auto_arima_fprint_statsforecast_
-

class ARIMASummary[source]

ARIMASummary(model)

+

class ARIMASummary[source]

ARIMASummary(model)

ARIMA Summary.

@@ -614,7 +614,7 @@

class ARIMASummary -

class AutoARIMA[source]

AutoARIMA(d:Optional[int]=None, D:Optional[int]=None, max_p:int=5, max_q:int=5, max_P:int=2, max_Q:int=2, max_order:int=5, max_d:int=2, max_D:int=1, start_p:int=2, start_q:int=2, start_P:int=1, start_Q:int=1, stationary:bool=False, seasonal:bool=True, ic:str='aicc', stepwise:bool=True, nmodels:int=94, trace:bool=False, approximation:Optional[bool]=None, method:Optional[str]=None, truncate:Optional[bool]=None, test:str='kpss', test_kwargs:Optional[str]=None, seasonal_test:str='seas', seasonal_test_kwargs:Optional[Dict[KT, VT]]=None, allowdrift:bool=True, allowmean:bool=True, blambda:Optional[float]=None, biasadj:bool=False, parallel:bool=False, num_cores:int=2, period:int=1)

+

class AutoARIMA[source]

AutoARIMA(d:Optional[int]=None, D:Optional[int]=None, max_p:int=5, max_q:int=5, max_P:int=2, max_Q:int=2, max_order:int=5, max_d:int=2, max_D:int=1, start_p:int=2, start_q:int=2, start_P:int=1, start_Q:int=1, stationary:bool=False, seasonal:bool=True, ic:str='aicc', stepwise:bool=True, nmodels:int=94, trace:bool=False, approximation:Optional[bool]=None, method:Optional[str]=None, truncate:Optional[bool]=None, test:str='kpss', test_kwargs:Optional[str]=None, seasonal_test:str='seas', seasonal_test_kwargs:Optional[typing.Dict]=None, allowdrift:bool=True, allowmean:bool=True, blambda:Optional[float]=None, biasadj:bool=False, parallel:bool=False, num_cores:int=2, period:int=1)

An AutoARIMA estimator.

Returns best ARIMA model according to either AIC, AICc or BIC value. @@ -829,27 +829,27 @@

References 1 - 483.363283 + 483.363282 2 - 490.196788 + 490.196787 3 - 489.549976 + 489.549975 4 - 485.653256 + 485.653255 5 - 481.407363 + 481.407362 6 - 478.248914 + 478.248913 @@ -909,45 +909,45 @@

References 0 - 426.326488 + 426.326487 464.631601 - 502.936715 + 502.936714 1 - 419.928953 - 483.363283 - 546.797613 + 419.928952 + 483.363282 + 546.797612 2 - 411.105076 - 490.196788 - 569.288501 + 411.105075 + 490.196787 + 569.288499 3 401.920876 - 489.549976 - 577.179076 + 489.549975 + 577.179074 4 393.609048 - 485.653256 - 577.697464 + 485.653255 + 577.697462 5 386.910310 - 481.407363 - 575.904416 + 481.407362 + 575.904414 6 382.073456 - 478.248914 - 574.424372 + 478.248913 + 574.424370 @@ -999,8 +999,8 @@

References - lo_90% lo_80% + lo_90% mean hi_80% hi_90% @@ -1009,59 +1009,59 @@

References 0 + 426.326487 415.467520 - 426.326488 464.631601 - 502.936715 + 502.936714 513.795682 1 - 401.946202 - 419.928953 - 483.363283 - 546.797613 - 564.780365 + 419.928952 + 401.946201 + 483.363282 + 546.797612 + 564.780363 2 + 411.105075 388.683674 - 411.105076 - 490.196788 - 569.288501 - 591.709902 + 490.196787 + 569.288499 + 591.709900 3 - 377.079244 401.920876 - 489.549976 - 577.179076 - 602.020708 + 377.079244 + 489.549975 + 577.179074 + 602.020706 4 - 367.515794 393.609048 - 485.653256 - 577.697464 - 603.790718 + 367.515794 + 485.653255 + 577.697462 + 603.790716 5 - 360.121709 386.910310 - 481.407363 - 575.904416 - 602.693017 + 360.121709 + 481.407362 + 575.904414 + 602.693015 6 - 354.809050 382.073456 - 478.248914 - 574.424372 - 601.688778 + 354.809051 + 478.248913 + 574.424370 + 601.688776 @@ -1143,7 +1143,7 @@

References 139 - 630.376069 + 630.376068 140 @@ -1240,7 +1240,7 @@

References 3 116.143488 136.303743 - 156.463999 + 156.463998 4 @@ -1256,9 +1256,9 @@

References 139 - 610.215814 - 630.376069 - 650.536324 + 610.215813 + 630.376068 + 650.536323 140 @@ -1345,40 +1345,40 @@

References 0 + 73.582887 62.723919 - 73.582886 111.888000 150.193114 161.052081 1 - 63.524432 74.383399 + 63.524432 112.688513 150.993626 - 161.852594 + 161.852593 2 - 71.583402 82.442370 + 71.583402 120.747483 159.052597 169.911564 3 - 87.139662 97.998630 + 87.139662 136.303743 174.608857 185.467824 4 - 75.745671 86.604639 + 75.745671 124.909752 163.214866 174.073833 @@ -1393,40 +1393,40 @@

References 139 - 581.211988 - 592.070955 - 630.376069 - 668.681182 - 679.540150 + 592.070954 + 581.211987 + 630.376068 + 668.681181 + 679.540149 140 - 518.791984 529.650951 + 518.791984 567.956065 606.261178 617.120146 141 + 413.509353 402.650385 - 413.509352 451.814466 490.119580 500.978547 142 - 394.334338 405.193306 + 394.334338 443.498419 481.803533 492.662500 143 - 324.924284 335.783252 + 324.924284 374.088365 412.393479 423.252446 @@ -1596,8 +1596,8 @@

References - lo_90% lo_80% + lo_90% mean hi_80% hi_90% @@ -1606,83 +1606,83 @@

References 0 - 434.808281 - 444.848076 - 480.263550 - 515.679025 - 525.718820 + 444.847963 + 434.808168 + 480.263437 + 515.678911 + 525.718706 1 - 398.250812 - 414.132285 - 470.154335 - 526.176385 - 542.057858 + 414.132100 + 398.250623 + 470.154163 + 526.176226 + 542.057702 2 - 403.968806 - 422.259587 - 486.780495 - 551.301404 - 569.592185 + 422.259329 + 403.968541 + 486.780261 + 551.301193 + 569.591981 3 - 379.813843 - 398.925989 - 466.344269 - 533.762548 - 552.874694 + 398.925698 + 379.813546 + 466.344002 + 533.762305 + 552.874457 4 - 381.849918 - 400.962063 - 468.380343 - 535.798623 - 554.910769 + 400.961769 + 381.849617 + 468.380072 + 535.798375 + 554.910527 5 - 383.880201 - 402.992346 - 470.410626 - 537.828906 - 556.941052 + 402.992047 + 383.879895 + 470.410351 + 537.828654 + 556.940806 6 - 385.904743 - 405.016888 - 472.435168 - 539.853448 - 558.965594 + 405.016585 + 385.904433 + 472.434888 + 539.853191 + 558.965344 7 - 387.923594 - 407.035740 - 474.454019 - 541.872299 - 560.984445 + 407.035432 + 387.923280 + 474.453735 + 541.872038 + 560.984191 8 - 389.936804 - 409.048950 - 476.467230 - 543.885510 - 562.997655 + 409.048638 + 389.936486 + 476.466941 + 543.885244 + 562.997397 9 - 391.944422 - 411.056568 - 478.474848 - 545.893128 - 565.005273 + 411.056252 + 391.944099 + 478.474555 + 545.892858 + 565.005010 @@ -1740,23 +1740,23 @@

References 0 - 73.205301 + 73.205186 1 - 116.318916 + 116.319149 2 - 100.318857 + 100.318853 3 - 107.862716 + 107.862723 4 - 108.927618 + 108.927698 ... @@ -1764,23 +1764,23 @@

References 139 - 608.317510 + 608.317523 140 - 564.682721 + 564.682620 141 - 429.362373 + 429.362250 142 - 442.344731 + 442.344697 143 - 391.284051 + 391.284005 @@ -1843,43 +1843,43 @@

References 0 - 27.750032 - 37.789827 - 73.205301 - 108.620776 - 118.660570 + 37.789712 + 27.749917 + 73.205186 + 108.620660 + 118.660455 1 - 70.863647 - 80.903442 - 116.318916 - 151.734390 - 161.774185 + 80.903675 + 70.863880 + 116.319149 + 151.734624 + 161.774418 2 - 54.863588 - 64.903383 - 100.318857 - 135.734332 - 145.774127 + 64.903379 + 54.863584 + 100.318853 + 135.734328 + 145.774123 3 - 62.407447 - 72.447242 - 107.862716 - 143.278191 - 153.317985 + 72.447249 + 62.407454 + 107.862723 + 143.278198 + 153.317993 4 - 63.472349 - 73.512144 - 108.927618 - 144.343093 - 154.382887 + 73.512224 + 63.472429 + 108.927698 + 144.343172 + 154.382967 ... @@ -1891,43 +1891,43 @@

References 139 - 562.862241 - 572.902036 - 608.317510 - 643.732985 - 653.772780 + 572.902048 + 562.862253 + 608.317523 + 643.732997 + 653.772792 140 - 519.227452 - 529.267247 - 564.682721 - 600.098196 - 610.137991 + 529.267145 + 519.227350 + 564.682620 + 600.098094 + 610.137889 141 - 383.907103 - 393.946898 - 429.362373 - 464.777847 - 474.817642 + 393.946776 + 383.906981 + 429.362250 + 464.777724 + 474.817519 142 - 396.889462 - 406.929257 - 442.344731 - 477.760206 - 487.800001 + 406.929222 + 396.889427 + 442.344697 + 477.760171 + 487.799966 143 - 345.828782 - 355.868577 - 391.284051 - 426.699526 - 436.739321 + 355.868531 + 345.828736 + 391.284005 + 426.699480 + 436.739275 @@ -1966,8 +1966,8 @@

References References - + diff --git a/docs/core.html b/docs/core.html index e464c91d2..558cc92b7 100644 --- a/docs/core.html +++ b/docs/core.html @@ -47,14 +47,20 @@ from statsforecast.models import ( adida, + auto_arima, croston_classic, + croston_optimized, + croston_sba, historic_average, + imapa, naive, + random_walk_with_drift, + seasonal_exponential_smoothing, seasonal_naive, seasonal_window_average, ses, - auto_arima, - random_walk_with_drift + tsb, + window_average, ) from statsforecast.utils import generate_series

@@ -77,7 +83,7 @@
-

class StatsForecast[source]

StatsForecast(df, models, freq, n_jobs=1)

+

class StatsForecast[source]

StatsForecast(df, models, freq, n_jobs=1, ray_address=None)

@@ -112,7 +118,11 @@

Daily data
fcst = StatsForecast(
     series,
-    [adida, (ses, 0.1), historic_average, croston_classic],
+    [adida, croston_classic, croston_optimized,
+     croston_sba, historic_average, imapa, naive, 
+     random_walk_with_drift, (seasonal_exponential_smoothing, 7, 0.1),
+     (seasonal_naive, 7), (seasonal_window_average, 7, 4),
+     (ses, 0.1), (tsb, 0.1, 0.3), (window_average, 4)],
     freq='D',
 )
 res = fcst.forecast(14)
@@ -123,144 +133,6 @@ 

Daily data

-
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsadidases_alpha-0.1historic_averagecroston_classic
unique_id
02000-08-10157.559219157.559219161.040253157.559219
02000-08-11157.559219157.559219161.040253157.559219
02000-08-12157.559219157.559219161.040253157.559219
02000-08-13157.559219157.559219161.040253157.559219
02000-08-14157.559219157.559219161.040253157.559219
..................
99992000-06-2787.64674487.64674478.27439987.646744
99992000-06-2887.64674487.64674478.27439987.646744
99992000-06-2987.64674487.64674478.27439987.646744
99992000-06-3087.64674487.64674478.27439987.646744
99992000-07-0187.64674487.64674478.27439987.646744
-

140000 rows × 5 columns

-
- -
- -
-
- {% endraw %} @@ -277,7 +149,9 @@

Parallel

-
if __name__=="__main__":
+
try: from nbdev.imports import IN_NOTEBOOK
+except: IN_NOTEBOOK=False
+if __name__=="__main__" and not IN_NOTEBOOK:
     fcst = StatsForecast(
         series,
         [adida, (ses, 0.1), historic_average, croston_classic],
@@ -292,48 +166,6 @@ 

Parallel

-
-
- -
- -
-
                  ds       adida  ses_alpha-0.1  historic_average  \
-unique_id                                                           
-0         2000-08-10  157.559219     157.559219        161.040253   
-0         2000-08-11  157.559219     157.559219        161.040253   
-0         2000-08-12  157.559219     157.559219        161.040253   
-0         2000-08-13  157.559219     157.559219        161.040253   
-0         2000-08-14  157.559219     157.559219        161.040253   
-...              ...         ...            ...               ...   
-9999      2000-06-27   87.646744      87.646744         78.274399   
-9999      2000-06-28   87.646744      87.646744         78.274399   
-9999      2000-06-29   87.646744      87.646744         78.274399   
-9999      2000-06-30   87.646744      87.646744         78.274399   
-9999      2000-07-01   87.646744      87.646744         78.274399   
-
-           croston_classic  
-unique_id                   
-0               157.559219  
-0               157.559219  
-0               157.559219  
-0               157.559219  
-0               157.559219  
-...                    ...  
-9999             87.646744  
-9999             87.646744  
-9999             87.646744  
-9999             87.646744  
-9999             87.646744  
-
-[140000 rows x 5 columns]
-
-
-
- -
-
-
{% endraw %} @@ -358,105 +190,6 @@

Monthly data <

-
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsy
unique_id
02000-06-300.317078
02000-07-311.183993
02000-08-312.458650
02000-09-303.396637
02000-10-314.160418
.........
99992001-04-307.087452
99992001-05-318.106541
99992001-06-309.162334
99992001-07-3110.052648
99992001-08-3111.327798
-

150180 rows × 2 columns

-
- -
- -
-
- {% endraw %} @@ -480,153 +213,6 @@

Monthly data < -
-
- -
- -
-
CPU times: user 3.03 s, sys: 10.6 ms, total: 3.05 s
-Wall time: 3.04 s
-
-
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsadidases_alpha-0.1historic_averagecroston_classic
unique_id
02001-09-304.0695334.1011104.8954694.101110
02001-10-314.0695334.1011104.8954694.101110
02001-11-304.0695334.1011104.8954694.101110
02001-12-314.0695334.1011104.8954694.101110
12001-09-306.4074275.6317096.5888765.631709
..................
99982001-12-314.3527805.7837005.0834815.783700
99992001-09-307.1661137.1661136.7897917.166113
99992001-10-317.1661137.1661136.7897917.166113
99992001-11-307.1661137.1661136.7897917.166113
99992001-12-317.1661137.1661136.7897917.166113
-

40000 rows × 5 columns

-
- -
- -
-
- {% endraw %} @@ -644,28 +230,6 @@

Monthly data < -
-
- -
- - - -
-
array([[ 5.039017 ],
-       [ 6.4191217],
-       [ 7.143789 ],
-       ...,
-       [ 9.162334 ],
-       [10.052649 ],
-       [11.327798 ]], dtype=float32)
-
- -
- -
-
- {% endraw %} @@ -709,74 +273,6 @@

Integer datestamp -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsy
unique_id
AirPassengers1112.0
AirPassengers2118.0
AirPassengers3132.0
AirPassengers4129.0
AirPassengers5121.0
-
- -
- -
- - {% endraw %} @@ -794,74 +290,6 @@

Integer datestamp -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsy
unique_id
AirPassengers140606.0
AirPassengers141508.0
AirPassengers142461.0
AirPassengers143390.0
AirPassengers144432.0
-
- -
- -
- - {% endraw %} @@ -882,74 +310,6 @@

Integer datestamp -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dshistoric_average
unique_id
AirPassengers145280.298615
AirPassengers146280.298615
AirPassengers147280.298615
AirPassengers148280.298615
AirPassengers149280.298615
-
- -
- -
- - {% endraw %} @@ -1023,196 +383,6 @@

External regressors -
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dsyinterceptdayofweek_1dayofweek_2dayofweek_3dayofweek_4dayofweek_5dayofweek_6
unique_id
02000-10-050.1238381001000
02000-10-061.4601131000100
02000-10-072.4185771000010
02000-10-083.3722321000001
02000-10-094.2419481000000
..............................
99992001-05-102.3388231001000
99992001-05-113.4026871000100
99992001-05-124.2355691000010
99992001-05-135.2103961000001
99992001-05-146.2388461000000
-

2769354 rows × 9 columns

-
- -
- -
- - {% endraw %} @@ -1242,21 +412,6 @@

External regressors -
- -
- -
-
CPU times: user 2.43 s, sys: 12.2 ms, total: 2.45 s
-Wall time: 2.44 s
-
-
-
- -
- - {% endraw %} @@ -1274,24 +429,6 @@

External regressors -
- -
- - - -
- -
- -
- -
- - {% endraw %} @@ -1322,24 +459,6 @@

Confidence intervals -
- -
- - - -
- -
- -
- -
- - {% endraw %} @@ -1377,7 +496,7 @@

n jobs

-
if __name__=="__main__":
+
if __name__=="__main__" and not IN_NOTEBOOK:
     ap_df = pd.DataFrame({'ds': np.arange(ap.size), 'y': ap}, index=pd.Index([0] * ap.size, name='unique_id'))
     fcst = StatsForecast(
         ap_df,
@@ -1393,27 +512,9 @@ 

n jobs

-
-
- -
- - - -
- -
- -
- -
-
-
{% endraw %}
- + diff --git a/docs/index.html b/docs/index.html index 6a0677b46..a039b49d2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -402,104 +402,6 @@

🧬 How to use -
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unique_iddsauto_arima_season_length-12seasonal_naive_season_length-12
0133424.16360
0134407.082342
0135470.861406
0136460.914396
0137484.901420
0138536.904472
0139612.903548
0140623.903559
0141527.903463
0142471.903407
0143426.903362
0144469.903405
- -
- -
- -
-
- {% endraw %} @@ -542,24 +444,6 @@

🧬 How to use -
-
- -
- - - -
- -
- -
- -
-
- {% endraw %} @@ -600,6 +484,7 @@

Adding external regressors - {% endraw %} @@ -780,6 +543,7 @@

Adding external regressors - {% endraw %} @@ -952,24 +618,6 @@

Adding external regressors -
- -
- - - -
- -
- -
- -
- - {% endraw %} @@ -990,5 +638,5 @@

📃 References - + diff --git a/docs/models.html b/docs/models.html index 9b8d6265a..451310c69 100644 --- a/docs/models.html +++ b/docs/models.html @@ -529,5 +529,5 @@

auto_arimaAirPassengers data