An Advanced Ensemble Deep Learning Framework for Stock Price Prediction Using VAE, Transformer, and LSTM Model

Anindya Sarkar, G. VadivuarXiv 2025 · DOI

Introduction

Predicting stock market movements remains a "holy grail" of financial analytics, yet it is notoriously difficult due to extreme volatility, market noise, and complex non-linear relationships. Traditional statistical models like ARIMA often fail during sudden market shifts, while standard machine learning approaches like SVMs or Random Forests struggle to capture long-term temporal dependencies.

Even individual deep learning architectures have inherent limitations: LSTMs can lose track of very long-range context, Transformers are prone to overfitting on smaller financial datasets, and Variational Autoencoders (VAEs) lack the mechanism to capture sequential patterns on their own. This paper proposes a hybrid ensemble framework that integrates these three architectures to leverage their individual strengths while mitigating their weaknesses.

Methodology: The Ensemble Framework

The proposed system utilizes a multi-stage pipeline designed to extract robust features and model both local and global dependencies.

Figure 1: The proposed system architecture, illustrating the flow from data ingestion and preprocessing to the ensemble model layer and final evaluation.

1. Feature Engineering and Preprocessing

The framework begins with data ingestion via the Yahoo Finance API. Beyond basic price data (Open, High, Low, Close, Volume), the authors calculate a comprehensive suite of technical indicators—including Logarithmic Returns, RSI, MACD, Bollinger Bands, and the Commodity Channel Index (CCI)—to provide the models with a richer context of market momentum and volatility.

2. The Model Trio

The core of the framework is an ensemble of three distinct deep learning models:

  • VAE (Variational Autoencoder): Used for dimensionality reduction and noise filtering, creating a "latent space" representation of the market data.
  • Transformer: Employs an 8-head multi-head attention mechanism to identify global patterns across a 60-day lookback window, capturing long-range dependencies.
  • LSTM (Long Short-Term Memory): Uses two stacked bidirectional layers (128 units each) to focus on local sequential dynamics and immediate price fluctuations.

3. Dynamic Weighted Integration

The final prediction is a weighted average of the three models: $y = w_1y_{VAE} + w_2y_{Transformer} + w_3y_{LSTM}$. While initial weights are set (0.3, 0.3, and 0.4 respectively), the framework allows for dynamic adjustments based on recent performance, enabling the system to adapt to changing market regimes.

Experimental Results

The model was tested on a diverse dataset covering multiple sectors, including large-cap tech, financial, industrial, and small-cap growth stocks. The ensemble framework significantly outperformed all baselines across several key metrics.

Figure 3: Visual comparison of actual vs. predicted stock prices, showing the model's ability to track general market trends over a long-term sequence.
  • Directional Accuracy: The ensemble reached 79.05%, a massive leap over ARIMA (52.3%), standalone LSTMs (65.7%), and single Transformers (68.2%).
  • Error Reduction: The system achieved a Mean Absolute Percentage Error (MAPE) of 3.299% and a Root Mean Squared Error (RMSE) of 10.5352, indicating tight alignment with actual price movements.
  • Explanatory Power: An $R^2$ score of 0.4284 suggests the model captures nearly 43% of the variance in inherently chaotic financial markets.

Discussion and Limitations

The synergy between VAE, Transformer, and LSTM architectures allows the model to balance noise reduction, global context, and local momentum. However, the authors identify areas for further exploration:

  • Computational Intensity: Training and running three distinct deep learning architectures simultaneously is more computationally expensive than single-model approaches.
  • Purely Technical Focus: The model currently relies on price and volume data. Incorporating "alternative data" like news sentiment or macroeconomic indicators could improve performance during sudden, event-driven market shifts.
  • Weight Optimization: More research is needed on the specific algorithms used to trigger dynamic weight shifts in real-time trading environments to ensure the ensemble remains optimal as market conditions evolve.

Summary updated

BibTeX
@misc{sarkar2025advanced,
  author = {Anindya Sarkar and G. Vadivu},
  title = {{An Advanced Ensemble Deep Learning Framework for Stock Price Prediction Using VAE, Transformer, and LSTM Model}},
  year = {2025},
  eprint = {2503.22192},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.22192},
}
Figure