Code and data for the paper Machine Learning Models Accurately Predict Stock Market Crashes Using Macroeconomic Indicators (Aarav Pulsani, Texas A&M University).
This project uses supervised machine learning to predict U.S. stock market crashes at a six-month forward horizon. A crash is defined as a decline of 20% or more in the S&P 500 from its most recent peak, consistent with the conventional definition of a bear market. Monthly data from January 1990 through December 2023 (408 observations) were retrieved from FRED, the Bureau of Labor Statistics, the CBOE, and Robert Shiller's online dataset.
Ten monthly macroeconomic indicators are used as model inputs, expanded to 30 features with 3-month and 12-month rolling averages:
| Feature | Type |
|---|---|
| S&P 500 Monthly Return | Change |
| 10Y-2Y Treasury Yield Spread | Level |
| Unemployment Rate | Change |
| CPI Inflation Rate | Change |
| Federal Funds Rate | Level |
| CBOE VIX | Level |
| Shiller CAPE Ratio | Level |
| Industrial Production Index | Change |
| Consumer Confidence Index | Level |
| M2 Money Supply Growth | Change |
Five classifiers were implemented with scikit-learn and tuned via grid search with cross validation: logistic regression, decision tree, random forest, support vector machine, and multi-layer perceptron.
| Model | Accuracy | AUC |
|---|---|---|
| Random Forest | 0.83 | 0.88 |
| Multi-Layer Perceptron | 0.81 | 0.86 |
| Support Vector Machine | 0.80 | 0.84 |
| Decision Tree | 0.75 | 0.78 |
| Logistic Regression | 0.71 | 0.74 |
Permutation feature importance identified the 10Y-2Y Treasury yield spread and the CBOE VIX as the most predictive features across all models, consistent with their established roles as recession and fear gauges.
- Python 3.9+
- pandas, numpy, scikit-learn, matplotlib
pip install pandas numpy scikit-learn matplotlibClone the repository and run the analysis script to reproduce the dataset construction, model training, evaluation, and figures from the paper.
git clone https://github.com/s155003/stock-crash-ml.git
cd stock-crash-mlIf you use this code or data, please cite:
A. Pulsani, "Machine learning models accurately predict stock market crashes using macroeconomic indicators," 2026.