iT邦幫忙

2022 iThome 鐵人賽

DAY 15
0

未完待續

from fbprophet import Prophet

model_fbp = Prophet()
for feature in features:
    model_fbp.add_regressor(feature)

model_fbp.fit(df_train[["date", "y"] + features].rename(columns={"date": "ds", "y": "y"}))
forecast = model_fbp.predict(df_valid[["date", "y"] + features].rename(columns={"date": "ds"}))
df_valid["Forecast_Prophet"] = forecast.yhat.values
from sklearn.metrics import mean_absolute_error, mean_squared_error

fig = go.Figure()
fig.add_trace(go.Scatter(x=df_valid.date, y=df_valid.y, name='close'))
fig.add_trace(go.Scatter(x=df_valid.date, y=df_valid.Forecast_ARIMAX, name='Forecast_ARIMAX'))
fig.add_trace(go.Scatter(x=df_valid.date, y=df_valid.Forecast_Prophet, name='Forecast_Prophet'))
fig.show()

print("RMSE of Auto ARIMAX:", np.sqrt(mean_squared_error(df_valid.y, df_valid.Forecast_ARIMAX)))
print("RMSE of Prophet:", np.sqrt(mean_squared_error(df_valid.y, df_valid.Forecast_Prophet)))
print("\nMAE of Auto ARIMAX:", mean_absolute_error(df_valid.y, df_valid.Forecast_ARIMAX))
print("MAE of Prophet:", mean_absolute_error(df_valid.y, df_valid.Forecast_Prophet))

上一篇
股價預測篇-建模part7(金融類)
下一篇
股價預測篇-建模part9(金融類)
系列文
從無到有,爬蟲-分析-預測建模,把實務面常見問題逐一釐清18
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言