Scully, Keith (2024) Investigating the Application of Tree-Based Machine Learning Techniques to Predict the Margin of Safety in Potential Stock Investments. Masters thesis, Dublin, National College of Ireland.
Preview |
PDF (Master of Science)
Download (1MB) | Preview |
Preview |
PDF (Configuration Manual)
Download (649kB) | Preview |
Abstract
The stock market provides generous conditions for increasing and preserving wealth over the long term. Value investing is a strategy focused on using fundamental analysis to estimate the intrinsic value of a company, then seeking to take advantage of divergences between market price and intrinsic value to minimise downside risk and maximise upside potential. This mispricing delta is regularly referred to in the investing world as the “margin of safety”. Valuing a business is a complex task requiring specialised knowledge and consequently is routinely neglected by many investors. This leads to buying decisions that are based more on intuition and market momentum rather than by informed decision-making, which is often at an increased risk of financial loss. This research proposes a novel approach to directly estimate the “margin of safety” available on US company stocks by leveraging machine learning techniques to predict the degree of mispricing based on current market prices and publicly available financial accounting data. A number of tree-based learning algorithms were selected and appropriate predictive models were developed. The final XGBoost model was found to be most performant with an RMSE of 8.7%. Using SHAP explainable AI techniques it was also determined that elevated levels of Free Cash Flow were strongly associated with enhanced margin of safety values. Further experimentation with the final model using unseen historical data revealed that a portfolio of stocks selected based on model outputs had significantly outperformed the broader stock market over a recent 10-year period. This study demonstrates that machine learning can be applied successfully to value investing approaches, through the selection of investments that are grounded on current price alongside fundamental business performance. The results are encouraging for retail investors who can benefit from this research by being more informed on the risk of investing given current market pricing, while simultaneously increasing the potential of positive investment returns into the future.
Actions (login required)
![]() |
View Item |