We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
PytorchForecastingTransform._calculate_freq_unit not work correctly with 'MS' freq for example
PytorchForecastingTransform._calculate_freq_unit
It should work correctly for any defualt pandas frequency.
import pandas as pd from etna.datasets.tsdataset import TSDataset from etna.pipeline import Pipeline from etna.transforms import DateFlagsTransform from etna.transforms import LagTransform from etna.metrics import SMAPE from etna.transforms import PytorchForecastingTransform from pytorch_forecasting.data import GroupNormalizer from etna.models.nn import DeepARModel from datetime import datetime import warnings current_time_start = datetime.now().time() original_df = pd.read_csv( "examples/data/example_dataset.csv", sep=',' ) print(original_df) df = TSDataset.to_dataset(original_df) df.index = pd.Index(pd.date_range("2021-01-01", freq="MS", periods=len(df)), name="timestamp") ts = TSDataset(df, freq="MS") print(ts) HORIZON = 1 transform_date = DateFlagsTransform(month_number_in_year=True, day_number_in_week=False, day_number_in_month=False, out_column="regressor_dateflag") num_lags = 10 transform_lag = LagTransform(in_column="target", lags=[HORIZON+i for i in range(num_lags)], out_column="regressor_target_lag") lag_columns = [f"regressor_target_lag_{HORIZON+i}" for i in range(num_lags)] transform_deepar = PytorchForecastingTransform( max_encoder_length=HORIZON, max_prediction_length=HORIZON, time_varying_known_reals=["time_idx"]+lag_columns, time_varying_unknown_reals=["target"], time_varying_known_categoricals=["regressor_dateflag_month_number_in_year"], target_normalizer=GroupNormalizer(groups=["segment"]), ) model_deepar = DeepARModel(max_epochs=3, learning_rate=[0.01], gpus=0, batch_size=64) metrics = [SMAPE()] pipeline_deepar = Pipeline( model=model_deepar, horizon=HORIZON, transforms=[transform_lag, transform_date, transform_deepar] ) # metrics_deepar, forecast_deepar, fold_info_deepar = pipeline_deepar.backtest(ts, metrics=metrics, n_folds=3, n_jobs=1) pipeline_deepar.fit(ts=ts) forecasted = pipeline_deepar.forecast() print(forecasted)
No response
The text was updated successfully, but these errors were encountered:
Possible workaround -- to change timestamp index with dummy timestamp index with daily frequency
Sorry, something went wrong.
martins0n
Successfully merging a pull request may close this issue.
🐛 Bug Report
PytorchForecastingTransform._calculate_freq_unit
not work correctly with 'MS' freq for exampleExpected behavior
It should work correctly for any defualt pandas frequency.
How To Reproduce
Environment
No response
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: