Is it possible to predict data with 11 months cycle?

Open
#2,657 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
matplotlib, pandas, python

Research direction

Start with the supplied Python example and attached 11month_span.csv, then inspect Prophet's add_seasonality() and make_future_dataframe() behavior for the 11-month pattern. Define the requested behavior and completion criteria around automatically identifying the cycle and producing a forecast that follows the demonstrated shifting peaks without manually setting the period.

Written by the indexing model from the issue text.

Description

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")
Dominant language
Python
Stars
20.5k
Forks
4.6k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebook/prophet

All issues in facebook/prophet

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.