Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The prediction result of spike data is unstable #229

Open
nai-kon opened this issue Jan 31, 2025 · 0 comments
Open

The prediction result of spike data is unstable #229

nai-kon opened this issue Jan 31, 2025 · 0 comments

Comments

@nai-kon
Copy link

nai-kon commented Jan 31, 2025

Thank you for this great project.

I have monthly data which is usually 0 and spikes in a constant cycle.
Here is a sample with 6 month cycle.

date, value
2020/4/1, 0
2020/5/1, 70
2020/6/1, 0
2020/7/1, 0
2020/8/1, 0
2020/9/1, 0
2020/10/1, 0
2020/11/1, 71
2020/12/1, 0
2021/1/1, 0
2021/2/1, 0
2021/3/1, 0
2021/4/1, 0
2021/5/1, 71
2021/6/1, 0

Here is the inference result. The peak is predicted correctly, but 0 is unstable.

Image

I think this is because there is little (or no) spike data like this in the training data, as general time series data tends to constantly fluctuate.
Is there a way to make 0 stable?

sample data and code

test.csv

df = pd.read_csv("test.csv")
df.ds = pd.to_datetime(df.ds)
df["unique_id"] = "dummy"

train_data = df[df.ds < "2024-1"]

tfm = timesfm.TimesFm(
      hparams=timesfm.TimesFmHparams(
          backend="gpu",
          per_core_batch_size=32,
          horizon_len=15,
          num_layers=50,
          use_positional_embedding=False,
          context_len=2048,
      ),
      checkpoint=timesfm.TimesFmCheckpoint(
          huggingface_repo_id="google/timesfm-2.0-500m-pytorch"),
)

pred = tfm.forecast_on_df(
    inputs=train_data,
    freq="MS",
    value_name="y",
    num_jobs=-1,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant