EngiSphere icone
EngiSphere

Hidformer: How a New AI Model is Changing the Game in Stock Price Prediction 📊🤖

Published January 7, 2025 By EngiSphere Research Editors
Financial Chart © AI Illustration
Financial Chart © AI Illustration

The Main Idea

The research introduces Hidformer, a Transformer-based neural network designed to improve stock price forecasting by leveraging dual-tower architecture and advanced attention mechanisms, outperforming traditional AI models in prediction accuracy and trading returns.


The R&D

The world of finance is a rollercoaster ride, and predicting stock prices is like trying to forecast the weather – tricky, unpredictable, and often full of surprises! But thanks to advancements in artificial intelligence (AI) and machine learning (ML), researchers are getting better at making sense of financial market chaos. One such breakthrough is the Hidformer model – a cutting-edge, Transformer-based neural network specifically designed for time series forecasting, including stock prices.

In this article, we’ll break down the Hidformer research, explore how it works, and discuss its potential to revolutionize stock market predictions. Ready? Let’s dive in! 🌟

Why Predicting Stock Prices Is Tough 🏋️‍♂️

The stock market moves fast, influenced by countless factors – global events, economic policies, company performance, and even social media buzz. For decades, analysts have relied on technical analysis, studying charts and patterns to predict future prices. However, human intuition has its limits, and that’s where machine learning comes in.

Traditional AI models like Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Long Short-Term Memory (LSTM) networks have been used to predict stock prices. Traditional models often face difficulties capturing long-term dependencies within time series data. This is where Transformers excel!

What Are Transformers? 🧠

Originally designed for natural language processing (NLP), Transformers are powerful AI models that understand sequences of data. Unlike RNNs that process data step by step, Transformers can process an entire sequence at once, thanks to their self-attention mechanism. This makes them highly efficient at capturing long-term patterns.

But there’s a catch – Transformers aren’t perfect for time series data, which is why researchers have been tweaking them to fit financial forecasting. Enter the Hidformer model!

Meet Hidformer: The Star of the Show 🎉

The Hidformer model is a specialized version of the Transformer, designed to tackle the unique challenges of predicting stock prices. Here’s what makes it stand out:

1. Two-Tower Architecture

Hidformer processes stock data using two separate “towers” – one for time domain analysis and another for frequency domain analysis. This dual approach ensures that the model captures both short-term and long-term trends in stock prices.

2. Segment-and-Merge Approach

Instead of processing the entire time series at once, Hidformer breaks it down into smaller segments. After processing each segment, the model merges the results, improving its ability to detect patterns in the data.

3. Recursive and Linear Attention Mechanisms

The classic multi-head attention mechanism in Transformers is replaced with recursive attention for time sequences and linear attention for frequency sequences. This change makes the model more efficient at handling large datasets.

4. MLP-Type Decoder

Hidformer’s decoder is a Multi-Layer Perceptron (MLP), which simplifies the prediction process by outputting long-term forecasts in a single step.

The Experiment: Testing Hidformer’s Power 📝

To test Hidformer’s effectiveness, researchers used stock price data from six major companies:

  • Apple (AAPL)
  • Coca-Cola (KO)
  • Altria Group (MO)
  • PepsiCo (PEP)
  • Procter & Gamble (PG)
  • Toyota (TM)

The dataset covered over 40 years of stock prices, from 1980 to 2023. The researchers trained the Hidformer model on 95% of this data and used the remaining 5% to evaluate its performance.

They compared Hidformer to traditional models like CNNs, RNNs, LSTMs, and Deep Neural Networks (DNNs). The results? Hidformer outperformed the competition in terms of prediction accuracy and trading returns!

Key Findings: What Makes Hidformer Shine? 💡
1. Better Prediction Accuracy

Hidformer showed lower error rates compared to other models:

ModelMean Absolute Error (MAE)Mean Squared Error (MSE)Mean Absolute Percentage Error (MAPE)
CNN0.1600.03967%
RNN0.1980.05587%
LSTM0.1890.05283%
DNN0.1630.04266%
Hidformer0.1590.04066%
2. Higher Trading Returns

Hidformer also excelled in backtesting trading strategies. It predicted upward, downward, and mixed market trends more accurately, helping investors make informed decisions.

For example, the 2-year backtest results showed Hidformer achieving significantly higher net values compared to other models.

Future Prospects: What’s Next for Hidformer? 🚀

The Hidformer model opens up exciting possibilities for the future of stock price prediction. Here are some potential developments:

1. Real-Time Predictions

With further optimization, Hidformer could be used to provide real-time stock predictions, helping investors make quick decisions based on up-to-the-minute data.

2. Multi-Sector Analysis

Currently, the model focuses on individual sectors. In the future, researchers could train it to analyze multiple sectors simultaneously, offering a more comprehensive market view.

3. Risk Management

Hidformer’s ability to predict market trends could be combined with risk management tools, helping investors minimize losses during volatile market periods.

4. Integration with Algorithmic Trading

Hidformer could be integrated into algorithmic trading platforms, automating the process of buying and selling stocks based on AI-driven insights.

5. Beyond Finance

The Hidformer model’s potential goes far beyond stock markets, offering game-changing applications in fields like:

  • Hydrology, where it can predict floods and water flows;
  • Energy systems, optimizing power grids and renewable energy use;
  • Climate science, enhancing long-term weather forecasts;
  • Transportation engineering, improving traffic management and route planning;
  • and even healthcare, predicting patient trends from monitoring devices.

Its ability to handle complex time series data could revolutionize decision-making across engineering disciplines, making systems smarter, more efficient, and more resilient. 🌍📈⚙️

Final Thoughts: The Future of Stock Prediction Is Here! 🌟

The Hidformer model represents a significant leap forward in stock price prediction. By combining the power of Transformers with innovative enhancements, it outperforms traditional models and opens up new possibilities for financial forecasting.

While no model can guarantee 100% accuracy in predicting the unpredictable world of finance, Hidformer’s performance shows that AI is becoming an invaluable tool for investors.

The Hidformer model isn't just a game-changer for stock markets — its ability to handle complex time series data could revolutionize fields like hydrology for predicting floods, energy systems for optimizing power grids, climate science for forecasting weather patterns, and even transportation engineering for managing traffic flows. The possibilities span across engineering disciplines, making smarter, data-driven decision-making a reality in everything from infrastructure planning to environmental protection. 🌧️⚡🚦🌱


Concepts to Know


Source: Kamil Ł. Szydłowski, Jarosław A. Chudziak. Hidformer: Transformer-Style Neural Network in Stock Price Forecasting. https://doi.org/10.48550/arXiv.2412.19932

From: Warsaw University of Technology

© 2025 EngiSphere.com