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

Is it possible to predict data with 11 months cycle? #2657

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

Is it possible to predict data with 11 months cycle? #2657

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

Comments

@nai-kon
Copy link

nai-kon commented Jan 30, 2025

I have a monthly data with 11months cycle like below.
The peak appears every 11 months and shifts by one month each year.
Image
(the data is very simplified for explanation)

I tried to predict it with Prophet but the result was incorrect.
Image

I also tried with 12 months cycle data and the result was correct.
Image

Prophet analyzes seasonality on a weekly or yearly basis. So it seems that data with cycles that are not divisors of 12 (11 months, 24 months, etc.) cannot be predicted correctly.

It seems that manually set cycle to add_seasonality() will solve the problem, but the cycle depends on the dataset so it need to automatically analyze the cycle from the data.

Sample data and code

11month_span.csv

import pandas as pd
import matplotlib.pyplot as plt
from prophet import Prophet

df = pd.read_csv("11month_span.csv")
df["date"] = pd.to_datetime(df["date"])
df.columns = ["ds", "y"]

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

model = Prophet()
model.fit(train_data)

future = model.make_future_dataframe(periods=12, freq="MS")
pred = model.predict(future)

model.plot(pred, include_legend=True)
plt.savefig("test.png")
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