Nixtla / mlforecast

Scalable machine 🤖 learning for time series forecasting.
https://nixtlaverse.nixtla.io/mlforecast
Apache License 2.0
789 stars 74 forks source link

Mlforecast + AutoDifferences + fitted=True #319

Open GGA-PERSO opened 4 months ago

GGA-PERSO commented 4 months ago

What happened + What you expected to happen

Test of the new target transformation available in 0.11.8 AutoDifferences, AutoSeasonalDifferences, AutoSeasonalityAndDifferences

I am experimenting issue while fitting the model when fitted=True (in order to get insample forecast)

image

Versions / Dependencies

version 0.11.8

Reproduction script

import matplotlib.pyplot as plt import numpy as np import pandas as pd from datasetsforecast.m4 import M4 from sklearn.base import BaseEstimator

from mlforecast import MLForecast from mlforecast.target_transforms import Differences, LocalStandardScaler, AutoDifferences, AutoSeasonalDifferences, AutoSeasonalityAndDifferences

data_path = 'data' await M4.async_download(datapath, group='Hourly') df, * = M4.load(data_path, 'Hourly') df['ds'] = df['ds'].astype('int32') serie = df[df['unique_id'].eq('H196')]

mlfcst = MLForecast( models=[], freq=1, target_transforms=[AutoDifferences(max_diffs=1)], ) without_trend_and_seasonality = mlfcst.preprocess(serie)

mlfcst.fit(without_trend_and_seasonality.dropna(), id_col='unique_id', time_col='ds', target_col='y', fitted=True, dropna=True)

Issue Severity

Low: It annoys or frustrates me.

helderPereira22 commented 4 months ago

I have the same issue, it would be amazing if you solve this!

ThomasDataScienc commented 3 months ago

Hello, it would be very nice if you could add this. For the moment we can’t use autodifference, which represent a very interesting feature. Thank you in advance.