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
456 stars 73 forks source link

Pyaf 5.0 Final Touch 7 : Improve the Guess of Window Length for Moving Average Trends #238

Closed antoinecarme closed 1 year ago

antoinecarme commented 1 year ago

Moving Average and Moving Median Trends are using windows of variable lengthds. These lengths are by default

https://github.com/antoinecarme/pyaf/blob/4ab4a659801ba2d48ca519f605d6d97754879922/pyaf/TS/Options.py#L223

These lengths can be customized according to the time resolution detected in the dataset. A daily signal can have [5, 7, 30] windows (business week , week, month). An hourly signal can have [12, 24] (half-day, day) windows.

The user choice, of course, will override this setting.

This issue only impacts slow modeling processes. Will not have impact by default.

Model Trend Explainability improves.

antoinecarme commented 1 year ago

New settings by default

    def get_moving_window_lengths_for_time_resolution(self, iResolution):
        # self.mOptions.mMovingAverageLengths self.mOptions.mMovingMedianLengths 
        lWindows = {}
        lWindows[eTimeResolution.SECOND] = [60] # Minute
        lWindows[eTimeResolution.MINUTE] = [60] # Hour
        lWindows[eTimeResolution.HOUR] = [12, 24] # Half-Day, Day
        lWindows[eTimeResolution.DAY] = [5, 7, 30] # Business Week, Week, Month
        lWindows[eTimeResolution.MONTH] = [3, 6, 12] # 3, 6 and 12 months
        return lWindows.get(iResolution , [])
antoinecarme commented 1 year ago

FIXED.