An AI-powered Financial Pipeline & Dashboard predicting whether a stock will BEAT or MISS its quarterly earnings.
Earnings Surprise Predictor is a sophisticated end-to-end Machine Learning pipeline tailored for the stock market. It gathers historical earnings estimates and price data, engineers over 10 distinct predictive financial features (like analyst dispersion, rolling surprises, and price momentum), trains an XGBoost classifier, and serves the live predictions through an elegant, glassmorphic web dashboard.
- Automated Synthetic Data Pipeline: Generates highly realistic financial data across 20 tickers over 20 quarters.
- Advanced Feature Engineering: Calculates metrics like
surprise_last_q,price_mom_20d,analyst_dispersion, andvol_ratio. - Predictive Modeling: Leverages XGBoost to classify outcomes as
BEAT(EPS > Consensus) orMISS. - Backtesting Engine: Simulates algorithmic trading performance based on the model's predictions over time.
- Model Explainability: Integrates SHAP (SHapley Additive exPlanations) to demystify black-box predictions.
- Glassmorphism UI: A gorgeous, dark-themed Flask frontend equipped with interactive Plotly.js charts.
The intuitive dashboard features:
- Model Summary: High-level KPIs including Out-of-Sample AUC, Sharpe Ratio, Total Return, and Win Rate.
- Back-test Equity Curve: An interactive time-series chart mapping the hypothetical growth of a $100K portfolio.
- Live Predictions: Real-time ticker query endpoint.
- Model Explainability: Visual breakdowns of feature importance and prediction drivers.
graph TD
A[Data Pipeline] -->|Synthesize & Merge| B(Feature Engineering)
B -->|Calculate Momentum & Surprises| C{XGBoost Model}
C -->|Train & Evaluate| D[Model Artifacts]
D -->|xgb_best.pkl| E[Flask Backend]
D -->|Explainability| F[SHAP Plots]
D -->|Historical Performance| G[Backtest Engine]
G -->|Summary JSON & Equity CSV| E
F -->|Static Assets| E
E -->|REST API| H((Glassmorphism Dashboard))
style A fill:#4FD1C5,stroke:#0d1117,color:#111
style C fill:#9F7AEA,stroke:#0d1117,color:#fff
style H fill:#2d3748,stroke:#4FD1C5,color:#fff,stroke-width:2px
We believe in transparent AI. By using SHAP, we provide a global view of feature importance as well as local, granular explanations for individual predictions.
git clone https://github.com/Paramveersingh-S/earning-predictor.git
cd earning-predictorMake sure you have Python 3.10+ installed.
pip install -r requirements.txtExecute the full pipeline to generate data, engineer features, train the model, run backtesting, and export SHAP plots.
python run_pipeline.pyLaunch the Flask backend to serve the beautiful UI.
python web/app.pyGo to http://127.0.0.1:5000 in your browser!
earnings_predictor/
│
├── assets/ # README images and logo
├── data/ # CSVs: estimates, prices, features, predictions
├── models/ # Pickled XGBoost models (.pkl)
├── reports/ # Backtest output files (.json, .csv)
│
├── web/ # Flask application
│ ├── app.py # API endpoints and routing
│ ├── templates/ # HTML files (index.html)
│ └── static/
│ ├── css/style.css # Glassmorphism styling
│ └── shap/ # Generated SHAP visualization plots
│
├── run_pipeline.py # Single execution script for the entire pipeline
├── requirements.txt # Python dependencies
└── README.md # You are here!


