iT邦幫忙

2022 iThome 鐵人賽

DAY 15
0

未完待續

features = ['SMA_3','SMA_7','SMA_30','EMA_3','EMA_7','EMA_30','RSI','MACD','MACD_signal']

from pmdarima import auto_arima

# Standard steps for passing the data to auto_arima
model = auto_arima(df_train.y, exogenous=df_train[features], trace=True, error_action="ignore", suppress_warnings=True)
model.fit(df_train.y, exogenous=df_train[features])

forecast = model.predict(n_periods=len(df_valid), exogenous=df_valid[features])
df_valid["Forecast_ARIMAX"] = forecast
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.show()

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

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

尚未有邦友留言

立即登入留言