簡易檢索 / 詳目顯示

研究生: 吳方瑜
Wu, Fang-YU
論文名稱: 以隨機森林及LSTM預測台幣兌美元的匯率
Forecasting the TWD/USD Exchange Rate by Using Random Forest and LSTM Models
指導教授: 周榮華
Chou, Jung-Hua
學位類別: 碩士
Master
系所名稱: 工學院 - 工程科學系
Department of Engineering Science
論文出版年: 2025
畢業學年度: 113
語文別: 中文
論文頁數: 103
中文關鍵詞: 隨機森林LSTM機器學習交叉驗證匯率預測
外文關鍵詞: Random Forest, LSTM, Machine Learning, Cross Validation, Exchange Rate forecasts
相關次數: 點閱:31下載:18
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • 本研究旨在利用隨機森林(Random Forest)與長短期記憶網路(Long Short-Term Memory, LSTM)兩種模型,預測台幣兌美元(TWD/USD)的匯率變化。透過台灣加權股價指數(Taiwan Stock Exchange Capitalization Weighted Stock Index, TAIEX)、國際油價(如杜拜原油、布蘭特原油、西德州原油)、黃金價格、美國標普500指數,及台幣兌美元等七項經濟指標作為特徵資料,建立多變數時間序列資料集,並設計不同延遲日(如 7 日、14 日與 30 日)之特徵,觀察延遲變數對模型預測效果的影響,以及各項經濟指標對於台幣兌美元匯率的貢獻度。
      在分析設計中,本研究採用 5-fold 的時間序列交叉驗證,並結合隨機森林進行特徵重要性排序,以評估各變數在匯率預測中的貢獻程度。結果顯示,「USD/TWD 匯率」本身的歷史延遲值為預測最具代表性的特徵,其權重遠高於其他外部經濟變數,而美國標普500指數及金價則貢獻度最低。
      LSTM 模型在預測準確度方面優於 Random Forest。其中以 LSTM–7 日模型表現最佳,平均 R² 為 0.96,RMSE 約 0.15,MAX diff 為 1.74%,相較之下,Random Forest 模型的 R² 均低於 0.89,且 RMSE 約落在 0.27左右,MAX diff 也在 2.92% 左右,預測誤差較大。
      然而,LSTM 模型的計算時間成本高於 Random Forest。以 30 日資料為例,Random Forest 需時僅約 167 秒,而 LSTM 則需約 547 秒,顯示深度學習模型雖具高準確性,但在應用上需考量其運算資源與時間成本。
      本研究驗證了機器學習在匯率預測應用中的潛力,並指出適當的特徵選擇與時間延遲為提升模型準確率的關鍵因素。未來可進一步結合即時資料與金融事件因素,強化模型的預測實用性與靈敏度。

    The performance of both Random Forest (RF) and Long Short-Term Memory (LSTM) for forecasting the TWD/USD exchange rate is evaluated in this study. By constructing lag features with 7-day, 14-day, and 30-day intervals and employing 5-fold time series cross-validation, the models are comprehensively evaluated through metrics including MSE, RMSE, R², maximum difference percentage, and cloud execution time. The results indicate that the LSTM models have higher forecasting accuracy, particularly with the 7-day lag scenario, where the average R² is 0.96 and RMSE is 0.15. However, this accuracy comes at the cost of longer computational time. In contrast, Random Forest demonstrates faster computation and good performance in short-term prediction but suffers from reduced accuracy in volatile periods probably due to its lack of temporal awareness. Thus, both can predict the exchange rate reasonably well with appropriate feature selection and time delay. Additionally, feature analysis reveals that historical exchange rate values play a dominant role in both models.

    摘要 ii Extended Abstract iii 誌謝 viii 目錄 ix 表目錄 xi 圖目錄 xii 第1章 緒論 1 1.1 研究動機 1 1.2 研究目的 2 1.3 研究架構 3 1.4 研究流程 3 第2章 文獻回顧 4 2.1 匯率預測 4 2.1.1 早期經濟理論與匯率預測 4 2.1.2 時間序列模型的應用 5 2.1.3 機器學習在匯率預測的應用 5 2.2 隨機森林(Random Forest, RF)介紹 8 2.3 長短期記憶網路(Long Short-Term Memory, LSTM)介紹 10 第3章 研究方法 18 3.1 研究方法架構 18 3.2 研究方法 19 3.2.1 資料蒐集 19 3.2.2 資料預處理 25 3.2.3 特徵工程 27 3.2.4 機器學習模型 28 3.2.5 使用工具介紹 29 3.3 模型評估指標 30 3.3.1 均方誤差(Mean Square Error, MSE) 30 3.3.2 均方根誤差(Root Mean Square Error, RMSE) 31 3.3.3 R2分數(R-squared) 31 3.3.4 最大差值(maximum difference) 31 第4章 結果與討論 32 4.1 隨機森林模型預測結果 32 4.1.1 隨機森林訓練狀況 32 4.1.2 隨機森林7日預測結果 34 4.1.3 隨機森林14日預測結果 40 4.1.4 隨機森林30日預測結果 45 4.1.5 隨機森林多項性能指標結果 51 4.1.6 隨機森林特徵重要性分析 53 4.2 LSTM模型預測結果 55 4.2.1 LSTM訓練狀況 55 4.2.2 LSTM 7日預測結果 57 4.2.3 LSTM 14日預測結果 63 4.2.4 LSTM 30日預測結果 68 4.2.5 LSTM多項性能指標結果 74 4.2.6 LSTM特徵重要性分析 76 4.3 隨機森林與LSTM結果比較 78 第5章 結論與建議 82 5.1 結論 82 5.2 建議 83 參考文獻 84

    [1] Investing.com。USD/TWD - 美元 新臺幣。https://hk.investing.com/currencies/usd-twd-historical-data。
    [2] Razmi, A., Rapetti, M., & Skott, P. The real exchange rate and economic development. Structural change and economic dynamics, 23(2), 151-169, 2012.
    [3] Sherstinsky, A. Fundamentals of recurrent neural network (RNN) and long short-term memory (LSTM) network. Physica D: Nonlinear Phenomena, 404, 132306, 2020.
    [4] Richard, A. M. & Kenneth, R. Empirical exchange rate models of the seventies: Do they fit out of sample? Journal of International Economics. Volume 14, Issues 1–2, Pages 3-24, February 1983
    [5] Cassel, G. Abnormal Deviations in International Exchanges. The Economic Journal. Vol. 28, No. 112, pp. 413–415, 1918.
    [6] Keynes, J. M. A Tract on Monetary Reform. 1923.
    [7] Robert M. Capital Mobility and Stabilization Policy under Fixed and Flexible Exchange Rates. Canadian Journal of Economics and Political Science, Vol. 29, No. 4, pp. 475-485, Nov., 1963.
    [8] Dornbusch, R. Expectations and Exchange Rate Dynamics. Journal of Political Economy, Vol. 84, No. 6, pp. 1161–1176, 1976.
    [9] Box, G. E. P. & Jenkins, G. M. Time Series Analysis: Forecasting and Control. 1970.
    [10] Vuong, P. H., Dat, T. T., Mai, T. K., Uyen, P. H. , & Bao, P. T. Stock-price forecasting based on XGBoost and LSTM. Computer Systems Science &Engineering, 40(1), 2022.
    [11] Bollerslev, T. Generalized Autoregressive Conditional Heteroskedasticity. Journal of Econometrics, Vol. 31, No. 3, pp. 307–327. 1986.
    [12] Boulesteix, A.-L., Janitza, S., Kruppa, J., & König, I. R. Overview of Random Forest Methodology and Practical Guidance with Emphasis on Computational Biology and Bioinformatics: Random Forests in Bioinformatics. Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery, 2(6), 493–507, 2012.
    [13] Ferna ́ndez-Delgado, M., Cernadas, E., Barro, S., & Amorim, D. Do We Need Hundreds of Classifiers to Solve Real World Classification Problems? Journal of Machine Learning Research. 15:3133-3181, 2014.
    [14] Baybuza, I. Inflation Forecasting Using Machine Learning Methods. Russian Journal of Money and Finance. 77(4), 42–59, 2018.
    [15] Woloszko, N. Adaptive Trees: A New Approach to Economic Forecasting. OECD Economics Department. Paris Working Papers No. 1593, 2020.
    [16] Gawthorpe, K. Random Forest as a Model for Czech Forecasting. Prague Economic Papers, 30(3), 336-357, 2021.
    [17] Tsuji, C. Exchange Rate Forecasting via a Machine Learning Approach,. IBusiness. vol. 14, no. 03, pp. 119–126, 2022.
    [18] Wang, Y., Liu Y., Wang, M., & Liu, R. LSTM Model Optimization on Stock Price Forecasting, 2018 17th International Symposium on Distributed Computing and Applications for Business Engineering and Science (DCABES) , pp. 173-177, 2018.
    [19] Yu, S., Tian, L., Liu, Y., & Guo, Y. LSTM-XGBoost application of the model to the prediction of stock price. Artificial Intelligence and Security: 7th International Conference, ICAIS 2021, pp. 86-98, 2021.
    [20] Cutler, D. R., Edwards, T., Beard, K. , Cutler, A., Hess, K., Gibson, J., & Lawler, J.J. Random forests for classification in ecology. Ecology, 88(11), 2783–2792, 2007.
    [21] Klassen, M., Cummings, M., & Saldana, G. Investigation of random forest performance with cancer microarray data. Proceedings of the ISCA 23rd International Conference on Computers and Their Applications, CATA 2008, April 9-11, 2008, Cancun, Mexico, pp. 64-69, 2008.
    [22] Löw, F., Schorcht, G., Michel, U., Dech, S., & Conrad, C. Per-field crop classification in irrigated agricultural regions in Middle Asia using random forest and support vector machine ensemble. Proceedings of SPIE - The International Society for Optical Engineering, 8538, 2012.
    [23] Zaklouta, F., Stanciulescu, B., & Hamdoun, O. Traffic sign classification using K-d trees and random forests. In The 2011 international joint conference on neural networks (IJCNN), San Jose, CA, USA , pp. 2151–2155, 2011.
    [24] Yoon, J. Forecasting of Real GDP Growth Using Machine Learning Models: Gradient Boosting and Random Forest Approach. Comput Econ, 57, 247–265, 2021.
    [25] Goulet Coulombe, P., Leroux, M., Stevanovic, D., & Surprenant, S. How is machine learning useful for macroeconomic forecasting? Journal of Applied Econometrics, 37(5), 920-964, 2022.
    [26] 徐維志。以隨機森林為模式之美金/歐元匯率交易預測研究(碩士論文)。新北市:輔仁大學統計資訊學系應用統計碩士在職專班,2015。
    [27] Hidayat, I., Akbar, L. A. S. I., & Rachman, A. S. Prediksi Nilai Tukar Mata Uang Menggunakan Algoritma Long Short-Term Memory dan Random Forest. Journal of Computer System and Informatics (JoSYC). 6(1): 107-116, 2024.
    [28] Abir, S. I., Shiam, S. A. A., Zakaria, R. M., Shimanto, A. H., Arefeen, S. M. S., Dolon, M. S. A., Sultana, N., & Shoha, S. Use of AI-Powered Precision in Machine Learning Models for Real-Time Currency Exchange Rate Forecasting in BRICS Economies. Journal of Economics Finance and Accounting Studies. 6(6):66-83, 2024.
    [29] 王貞治。匯率預測模型績效之研究-時間序列及人工智慧模型之應用(碩士論文)。台北市:東吳大學經濟學系,2014。
    [30] 郭泓霆。以循環神經網路模型增進新台幣匯率的短期預測能力(碩士論文)。台北市:國立政治大學經濟學系,2018。
    [31] 簡崇益。匯率預測:結合時間序列模型與自注意力機制(碩士論文)。台北市:國立臺灣大學社會科學院經濟學系,2022。
    [32] Breiman, L. Random Forests. Machine Learning, Vol. 45, No. 1, pp. 5–32. 2001.
    [33] Wager, S., Athey, S. Estimation and Inference of Heterogeneous Treatment Effects using Random Forests. Journal of the American Statistical Association, 113(523), 1228–1242, 2018.
    [34] Hochreiter, S. & Schmidhuber, J. Long Short-Term Memory. Neural Computation, Vol. 9, No. 8, pp. 1735–1780, 1997.
    [35] Kaur, M., Mohta, A. A Review of Deep Learning with Recurrent Neural Network. International Conference on Smart Systems and Inventive Technology (ICSSIT), Tirunelveli, India, pp. 460-465, 2019.
    [36] Li, S., Li, W., Cook, C., Zhu, C., & Gao, Y. Independently Recurrent Neural Network (IndRNN): Building A Longer and Deeper RNN. In Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 5457-5466, 2018.
    [37] colah's blog. Understanding LSTM Networks. https://colah.github.io/posts/2015-08-Understanding-LSTMs/. 2025,04。
    [38] Investing.com。美國標準普爾500指數 (SPX)。https://hk.investing.com/indices/us-spx-500-historical-data。
    [39] Investing.com。臺灣加權指數 (TWII)。https://hk.investing.com/indices/taiwan-weighted-historical-data。
    [40] Investing.com。黃金期貨。https://hk.investing.com/commodities/gold-historical-data。
    [41] 經濟部能源署。國際原油價格。https://www2.moeaea.gov.tw/oil111/CrudeOil/Price。
    [42] Ratner, B. Statistical and machine-learning data mining: Techniques for better predictive modeling and analysis of big data. Chapman and Hall/CRC, 2017.
    [43] Nyman, R., Ormerod, P. Predicting economic recessions using machine learning algorithms. arXivpreprint arXiv:1701.01428, 2017.
    [44] Draper, N. R., & Smith, H. Applied Regression Analysis (3rd ed.), 1998.
    [45] Chai, T. & Draxler, R. R. Root mean square error (RMSE) or mean absolute error (MAE)? – Arguments against avoiding RMSE. Geoscientific Model Development, 7(3), 1247–1250, 2014.

    下載圖示 校內:立即公開
    校外:立即公開
    QR CODE