[Paper Review] Comparative Study of Machine Learning Models for Stock Price Prediction
This study compares machine learning models—specifically a linear Kalman filter and various LSTM architectures—for predicting next-day stock prices using 10 years of historical data. It finds that low-volatility stocks (e.g., MSFT) are best predicted by a Kalman filter, while high-volatility stocks (e.g., TSLA) require complex LSTMs like CNN-LSTM, with R² values up to 0.96, suggesting model selection should be volatility-dependent for optimal performance.
In this work, we apply machine learning techniques to historical stock prices to forecast future prices. To achieve this, we use recursive approaches that are appropriate for handling time series data. In particular, we apply a linear Kalman filter and different varieties of long short-term memory (LSTM) architectures to historical stock prices over a 10-year range (1/1/2011 - 1/1/2021). We quantify the results of these models by computing the error of the predicted values versus the historical values of each stock. We find that of the algorithms we investigated, a simple linear Kalman filter can predict the next-day value of stocks with low-volatility (e.g., Microsoft) surprisingly well. However, in the case of high-volatility stocks (e.g., Tesla) the more complex LSTM algorithms significantly outperform the Kalman filter. Our results show that we can classify different types of stocks and then train an LSTM for each stock type. This method could be used to automate portfolio generation for a target return rate.
Motivation & Objective
- To evaluate the effectiveness of machine learning models in forecasting next-day stock prices using historical time series data.
- To compare the performance of a linear Kalman filter against multiple LSTM architectures on stocks with varying volatility levels.
- To investigate whether trained LSTM models can generalize across different stocks or market indices without retraining.
- To explore the feasibility of using model clustering by volatility to automate portfolio generation or day-trading strategies.
Proposed method
- Used yfinance to collect 10-year historical stock prices (2011–2021) for technology stocks (MSFT, AAPL, TSLA) and market indices (NASDAQ, S&P 500).
- Applied a recursive linear Kalman filter with local variance estimation over the prior three days to balance prediction and measurement uncertainty.
- Implemented multiple LSTM variants: single-layer, dual-layer, bidirectional, and CNN-LSTM, with min-max scaling and 3D sequence formatting for time-series input.
- Trained models on 7.5 years of data and tested on the final 2.5 years, using inverse scaling to compare predictions with true prices.
- Evaluated model performance using RMSE, MAE, and R² metrics to quantify prediction accuracy across different stock types.
- Extended top-performing models (bidirectional and CNN-LSTM) to market indices (S&P 500 and Russell microcap) without retraining to test generalization.
Experimental results
Research questions
- RQ1Can a linear Kalman filter outperform deep learning models in predicting low-volatility stock prices?
- RQ2Do deeper or more complex LSTM architectures (e.g., bidirectional, CNN-LSTM) significantly improve prediction accuracy for high-volatility stocks?
- RQ3Can a single trained LSTM model generalize across different stocks or market indices with similar volatility characteristics?
- RQ4Is there a correlation between stock volatility and the relative performance of Kalman filters versus LSTMs in price forecasting?
Key findings
- For low-volatility stocks like MSFT, the Kalman filter achieved an R² of 0.99, outperforming all LSTM variants, including the bidirectional LSTM.
- For high-volatility stocks like TSLA, the CNN-LSTM model achieved the best performance with an RMSE of 2.20, MAE of 1.54, and R² of 0.96.
- The dual-layer LSTM performed worse than the Kalman filter for MSFT (RMSE 24.66), indicating that deeper architectures are not always better for stable stocks.
- The bidirectional LSTM achieved an R² of 0.99 for MSFT and 0.95 for TSLA, showing strong performance across volatility levels but not surpassing the CNN-LSTM on high-volatility data.
- Trained LSTM models (especially bidirectional and CNN-LSTM) generalized well to market indices without retraining, achieving R² values of 0.99 on both S&P 500 and Russell microcap indices.
- The results support a strategy of clustering stocks by volatility and training specialized models per cluster, enabling scalable automation of portfolio generation or algorithmic trading.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.