我预测的数据帧有17行,但它引发了值错误:传递值的长度是17,索引意味着1。 我如何预测未来数据帧的长度?在
运行于python=3.6.8,fbprophet版本=0.3 然后我只预测一行的数据帧。它起作用了。 我改变增长,n_变化点,变化点范围,每周的季节性,每天的季节性。它不起作用。 如果模型适合不同的数据,则长度限制将更改。在
def first_nonzero_index(serial):
# drop 0 ahead
for i in serial.index:
if serial[i] != 0:
return i
return None
def model_data_convert(sale_series, has_cap = False, has_floor = False):
item_id = sale_series.name
category_id = items.at[item_id, 'item_category_id']
start_month = first_nonzero_index(sale_series)
data = sale_series[start_month:].to_frame('y').reset_index()
data.columns = ['ds', 'y']
end_time = pd.Period('2015-10', 'M')
start_time = pd.Period('2013-01') + start_month
data['ds'] = pd.period_range(start_time.strftime('%Y%m'), end_time.strftime('%Y%m'), freq='M').to_timestamp(how = 'E')
if has_cap:
data['cap'] = catergory_cap.loc[category_id][start_month:].values
if has_floor:
data['floor'] = catergory_floor.loc[category_id][start_month:].values
return data
data = common_items_month_sales_without_seasonal.loc[38]
data = model_data_convert(data, has_cap=True, has_floor=True)
m = fbprophet.Prophet(n_changepoints=5,changepoint_range=0.5)
m.fit(data)
future = m.make_future_dataframe(periods=1, freq='M')
future['cap'] = data['cap']
future['floor'] = data['floor']
future = future.fillna(method='ffill')
forecast = m.predict(future)
^{pr2}$
^{3}$
目前没有回答
相关问题 更多 >
编程相关推荐