4

我的数据框看起来像这样。我的目标是根据12的数据预测event_id 3event_id event_id

ds tickets_sold y event_id
3/12/19 90  90  1
3/13/19 40  130 1
3/14/19 13  143 1
3/15/19 8   151 1
3/16/19 13  164 1
3/17/19 14  178 1
3/20/19 10  188 1
3/20/19 15  203 1
3/20/19 13  216 1
3/21/19 6   222 1
3/22/19 11  233 1
3/23/19 12  245 1
3/12/19 30  30  2
3/13/19 23  53  2
3/14/19 43  96  2
3/15/19 24  120 2
3/16/19 3   123 2
3/17/19 5   128 2
3/20/19 3   131 2
3/20/19 25  156 2
3/20/19 64  220 2
3/21/19 6   226 2
3/22/19 4   230 2
3/23/19 63  293 2

我想预测该数据未来 10 天的销售额:

ds  tickets_sold y event_id
3/24/19 20  20  3
3/25/19 30  50  3
3/26/19 20  70  3
3/27/19 12  82  3
3/28/19 12  94  3
3/29/19 12  106 3
3/30/19 12  118 3

到目前为止,我的模型就是那个。但是,我并没有告诉模型这是两个独立的事件。然而,考虑来自不同事件的所有数据将是有用的,因为它们属于同一组织者,因此提供的信息不仅仅是一个事件。Prophet 可以这样搭配吗?

# Load data
df = pd.read_csv('event_data_prophet.csv')
df.drop(columns=['tickets_sold'], inplace=True, axis=0)
df.head()

# The important things to note are that cap must be specified for every row in the dataframe,
# and that it does not have to be constant. If the market size is growing, then cap can be an increasing sequence.
df['cap'] = 500

# growth: String 'linear' or 'logistic' to specify a linear or logistic trend.
m = Prophet(growth='linear')
m.fit(df)

# periods is the amount of days that I look in the future
future = m.make_future_dataframe(periods=20)
future['cap'] = 500
future.tail()

forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

fig1 = m.plot(forecast)
4

1 回答 1

1

事件的开始日期似乎会导致高峰。您可以holidays通过将每个事件的开始日期设置为假期来使用此功能。这会告知先知事件(及其高峰)。我注意到事件 1 和 2 是重叠的。我认为你有多种选择来处理这个问题。你需要问自己每个事件的预测值与 event3 有什么关系。您没有太多数据,这将是主要问题。如果它们具有相同的价值,您可以更改一个事件的日期。例如 11 天前。不等值场景可能意味着您放弃 1 个事件。

events = pd.DataFrame({
  'holiday': 'events',
  'ds': pd.to_datetime(['2019-03-24', '2019-03-12', '2019-03-01']),
  'lower_window': 0,
  'upper_window': 1,
})

m = Prophet(growth='linear', holidays=events)
m.fit(df)

我还注意到你对 cumsum 的预测。我认为您的事件是固定的,因此先知可能受益于对每日门票销售量的预测,而不是对 cumsum 的预测。

于 2019-05-08T19:21:35.880 回答