antoinecarme / pyaf

PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.
BSD 3-Clause "New" or "Revised" License
459 stars 72 forks source link

How to handle intermittent demand never less than zero #90

Closed bb78657 closed 6 years ago

bb78657 commented 6 years ago

When forcasting physical quantities that can never be negative can we specify which algorithm to use (eg Crostons method).

For example when running test_sof_example.py but where the sof_example.csv has been modified to:

Date,Used 11/1/2011,587 11/2/2011,578 11/3/2011,600 11/4/2011,599 11/5/2011,678 11/6/2011,555 11/7/2011,650 11/8/2011,700 11/9/2011,600 11/10/2011,436 11/11/2011,309 11/12/2011,90 11/13/2011,34 11/14/2011,0 11/15/2011,0 11/16/2011,0 11/17/2011,0 11/18/2011,56 11/19/2011,203 11/20/2011,403 11/21/2011,639 11/22/2011,620 11/23/2011,600 11/24/2011,550 11/25/2011,600 11/26/2011,610 11/27/2011,590 11/28/2011,595 11/29/2011,601 11/30/2011,700 12/1/2011,650 12/2/2011,620 12/3/2011,645 12/4/2011,650 12/5/2011,639 12/6/2011,620 12/7/2011,600 12/8/2011,550 12/9/2011,423 12/10/2011,302 12/11/2011,201 12/12/2011,20 12/13/2011,0 12/14/2011,0 12/15/2011,0 12/16/2011,0 12/17/2011,102 12/18/2011,500 12/19/2011,639 12/20/2011,620 12/21/2011,600 12/22/2011,550 12/23/2011,600 12/24/2011,610 12/25/2011,590 12/26/2011,750 12/27/2011,750 12/28/2011,666 12/29/2011,412 12/30/2011,301 12/31/2011,200 1/1/2012,45 1/2/2011,0 1/3/2011,0 1/4/2011,0 1/5/2011,0 1/6/2011,0 1/7/2011,0

The resultant Quantity_Forecast contains negative values. While I can clip the output to zero if negative a more robust approach to intermittent demand where input and output is always >=0 would be great.

antoinecarme commented 6 years ago

Hi @bb78657

Someone already asked for this same feature :

https://github.com/antoinecarme/pyaf/issues/69

This issue was fixed. Can you please read the issue description , add the option described and check that this solves the problem for you ?

You can find some sample test scripts here :

https://github.com/antoinecarme/pyaf/tree/master/tests/bugs/issue_69

bb78657 commented 6 years ago

OK, that works, can close this issue