Skip to content

Commit

Permalink
fix frequency inference
Browse files Browse the repository at this point in the history
  • Loading branch information
wgifford committed Sep 18, 2024
1 parent e94eaa4 commit 0a9aa9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 2 additions & 0 deletions services/inference/tsfminference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def _forecast_common(self, input_payload: ForecastingInferenceInput) -> PredictO
# train to estimate freq if not available
preprocessor.train(data)

LOGGER.info(f"Data frequency determined: {preprocessor.freq}")

# warn if future data is not provided, but is needed by the model
if preprocessor.exogenous_channel_indices and future_data is None:
raise ValueError(
Expand Down
8 changes: 1 addition & 7 deletions tsfm_public/toolkit/time_series_forecasting_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Hugging Face Pipeline for Time Series Tasks"""

import inspect
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Union

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -116,13 +116,11 @@ def __init__(
self,
model: Union["PreTrainedModel"],
*args,
freq: Optional[str] = None,
explode_forecasts: bool = False,
inverse_scale_outputs: bool = True,
add_known_ground_truth: bool = True,
**kwargs,
):
kwargs["freq"] = freq
kwargs["explode_forecasts"] = explode_forecasts
kwargs["inverse_scale_outputs"] = inverse_scale_outputs
kwargs["add_known_ground_truth"] = add_known_ground_truth
Expand All @@ -142,10 +140,6 @@ def __init__(
if p not in kwargs:
kwargs[p] = getattr(kwargs["feature_extractor"], p)

# get freq from kwargs or the preprocessor
if "freq" not in kwargs:
kwargs["freq"] = kwargs["feature_extractor"].freq

if "context_length" not in kwargs:
kwargs["context_length"] = model.config.context_length

Expand Down

0 comments on commit 0a9aa9b

Please sign in to comment.