我正在运行这段代码。用先知预测多个时间序列,但不知道如何评估模型。
import pandas as pd
from fbprophet import Prophet
data = pd.read_csv(r'C:\Users\XXX.csv')
ids = data['id'].unique()
series = []
for id in ids:
f = data[data['id'] == id]
series.append(f)
def run_prophet(timeserie):
model = Prophet(yearly_seasonality=False,daily_seasonality=False)
model.fit(timeserie)
forecast = model.make_future_dataframe(periods=90, include_history=False)
forecast = model.predict(forecast)
return forecast
results = list(map(lambda timeserie: run_prophet(timeserie), series))
results[0]
results[1]
数据的结构是这样的:
id ds y
id1 2017-01-01 12
id2 2017-01-01 15
id3 2017-01-01 16
答案 0 :(得分:1)
您可以通过导入以下代码来做到这一点:
from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error
然后
r2_score(original price,predicted price)
其余的都一样
注意:两个数组的样本长度应相等。