Deep learning for stock price prediction: A comparative study of stacked and weighted ensemble models
Abstract
In this paper, we provide a unique ensemble-based framework that combines sophisticated deep learning architectures and novel ensemble algorithms to improve forecast accuracy and robustness. The framework includes the Stacking Ensemble Meta-Model, which aggregates predictions as meta-features that are processed by a linear regression meta-model. We also introduce an Optimized Weighted Ensemble model, which uses constrained optimization to compute optimal weights for combining predictions from LSTM, CNN, and Hybrid CNN/LSTM-Attention-based models. Our results show that our proposed ensemble meta-model framework outperforms the optimized weighted ensemble model, with improved predictive accuracy across the evaluation metrices.
Full text
Corresponding author: Md Talha Mohsin Copyright © 2025 Author(s) retain the copyright of this article. This article is published under the terms of the Creative Commons Attribution License 4.0. Deep learning for stock price prediction: A comparative study of stacked and weighted ensemble models Md Talha Mohsin 1, * and Arafat Asim 2 1 Department of Finance and Operations Management, University of Tulsa, 800 S Tucker Dr, Tulsa, OK 74104, USA. 2 Department of Cyber Studies, University of Tulsa, 800 S Tucker Dr, Tulsa, OK 74104, USA. World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 Publication history: Received on 02 August 2025; revised on 07 September 2025; accepted on 10 September 2025 Article DOI: https://doi.org/10.30574/wjarr.2025.27.3.3182 Abstract In this paper, we provide a unique ensemble-based framework that combines sophisticated deep learning architectures and novel ensemble algorithms to improve forecast accuracy and robustness. The framework includes the Stacking Ensemble Meta-Model, which aggregates predictions as meta-features that are processed by a linear regression metamodel. We also introduce an Optimized Weighted Ensemble model, which uses constrained optimization to compute optimal weights for combining predictions from LSTM, CNN, and Hybrid CNN/LSTM-Attention-based models. Our results show that our proposed ensemble meta-model framework outperforms the optimized weighted ensemble model, with improved predictive accuracy across the evaluation metrices. Keywords: Stock Market Prediction; Deep Learning; LSTM; CNN; Attention Mechanism; Ensemble Learning; Stacking; Weighted Ensemble; Time Series Forecasting; Hybrid Models 1. Introduction The stock market occupies a significant portion of a country’s financial market and stimulates the economy. For instance, sixty-six percent of the entire financial market of USA is made up of the stock market. With a total market capitalization of over $55.2 trillion, the U.S. stock market accounts for roughly 42.5% of the value of the global stock market. Predicting how the stock market will behave in the future allows one to determine the future trends, thus resulting in financial gain. So, naturally, there is significant profitability involved with predicting stock prices. However, the noise and complex behavior of prices in financial markets have shown that predicting their trends is not easy (1), and it is ever more important to look at the right factors to use to predict stocks. (2) also dictates the same, saying how the volatile and experienced periods of contraction as well as expansion of the financial market make the task of stock price prediction hard. As discussed by (3), the principle of market efficiency suggests that the individual investors cannot repeatedly gain returns above the market average by using available information, as prices adapt almost immediately to new information. The stock market, as a major financial market, is likewise highly volatile. However, even with all the uncertainties and the volatilities, the large potential upside of the stock market has resulted in a lot of effort into making these predictions. There are primarily two approaches generally used for stock price prediction: fundamental or traditional approach and the technical or computational approach. According to (4) the traditional or fundamental analysis approach focuses on stock’s intrinsic value and qualitatively analyzes external factors that affect stocks, such as interest rate, exchange rate, inflation, industrial policy, finance of listed companies, international relations, and other economic and political factors. The fundamental techniques focus on using conventional financial or statistical methods as well as well-established and ubiquitous financial principles to evaluate market behaviors. These methods rely on established heuristics and are somewhat limited in unearthing non-linear patterns. The technical approach, on the other hand, focuses on computational methods like machine learning and deep learning algorithms to
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 640 identify patterns and relations to predict the stock price changes. These methods capture stock markets’ non-linearity and dynamic nature by enabling exact shortand medium-term prediction. These computational methods emphasize the interdisciplinary and dynamic aspect of stock market, combining theoretical notions with the data-driven models. So, in recent years, there has been a significant increase in interest in the subject of stock market prediction, particularly in the context of machine learning. These predictions are usually made by analyzing previous time series data and numerous algorithms have been used to predict stock (5). Among the different machine learning algorithms used for stock price prediction, supervised learning and deep learning have been most widely used. For the purpose of this paper, we propose a novel approach featuring the Optimized Weighted Ensemble framework and the Stacking Ensemble MetaModel for stock price prediction. We applied constrained optimization for the Optimized Weighted Ensemble framework to identify the best weights for aggregating forecasts from distinct models including LSTM, CNN, and hybrid CNN-LSTM-Attention. This method shows a consistent and dependable ensemble that makes best use of the standalone model’s strengths, hence producing strong forecasts over multiple stock tickers. Additionally, we also provide a Stacking Ensemble Meta-Model, which combines the standalone model predictions as meta-features and uses a linear metamodel to generate final predictions. This multi-layered approach, which uses the output of the individual models as the input for the regression model, it enables the meta model to capture the intricate insights from the base models. This Stacking Ensemble Meta-Model surpasses the constraints of single-model approaches, which in turn improve the predictive capacity and generalizability of our framework. The remaining sections of the paper are structured as follows: The literature review is covered in Section 2, followed by the methodology in section 3, results and analysis are presented in Section 4, discussion is in Section 5, future direction is reported in Section 6, with a brief conclusion in Section 7. 2. Literature review It is needless to say that the potential for financial gain is a significant factor in the process of revealing the complexities of the stock market to try to achieve financial gains. Historically, stock prediction methodologies have evolved from fundamental analysis, emphasizing economic indicators and company financials, to technical analysis techniques that analyze patterns in historical price movements. Recently, there has been a significant change in focus towards the application of advanced machine learning techniques that can model complex nonlinear connections and handle large datasets in the financial domains. (6) explains how different ensemble machine learning techniques have shown excellent prediction accuracy in recent studies, garnering interest in the field of stock market prediction. Amidst the wide range of algorithms, Long-short term memory (LSTM), Random Forests (RF), Support Vector Machines (SVM), Gradient Boosting Trees (GBT), Neural networks (NN), Transformers models, and hybrid models etc. have become especially well-known. We have employed LSTM, CNN, and Hybrid CNN/LSTM-Attentionbased models for the purpose of our paper. 2.1. Machine Learning Approaches (7) has shown the efficacy of RF, GBT, deep neural networks (DNN), and several ensembles of these techniques in the context of statistical arbitrage on the S&P 500. (8) recommended combining predictions from an ensemble of trees in a Random Forest using LSboost (LS-RF). (9) on the other hand analyzed the link between stock-price and MVs in many sectors and forecasted a 30-day head stock price using RF with enhanced leave-one-out cross-valuation and LSTMRNN. (10) showed a way for selecting a collection of useful features from the lag indices using a genetic algorithm methodology. Then, the RF classifier is deployed to identify hidden connections between market indices and a specific stock trend. (11) used six traditional machine learning (ML) models and six deep neural network (DNN) models as classifiers to track the daily trading performance of stocks with and without transaction costs. Traditional machine learning methods used include Random Forest (RF), Bayesian Networks (BN), Classification and Regression Trees (CART), Logistic Regression (LR), Support Vector Machine (SVM), and eXtreme Gradient Boosting (XGB). Deep learning techniques used are Gated Recurrent Units (GRU), Recurrent Neural Networks (RNN), Long Short-Term Memory networks (LSTM), Multi-Layer Perceptrons (MLP), Deep Belief Networks (DBN), and Stacked Autoencoders (SAE). Among the 12 models, the results show that the DNN models perform better when taking transaction cost into account, but classical ML methods perform better across the majority of directional indicators (11). As per the research of (12), Gradient Boosting Machines (GBM) can learn from mistakes over and over, and lets any differentiable loss function be optimized, which makes them very good at complex financial prediction. In (5), When the prediction problem was reformulated as a classification problem, the model XGBoost performed noticeably better than the other techniques for financial time series prediction.(13) presented a learning architecture LR2GBDT, which
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 641 outperforms the other models in the forecasting and trading of stock indices by scaling the logistic regression (LR) model onto the gradient boosted decision trees (GBDT) models. (14) presented an SVM-based technique for forecasting stock market trends. In this research, a correlation-based SVM filter is used to rank and pick a subset of financial indices, and the stock indicators are then analyzed based on their ranking. Also, a quasi-linear SVM is used to predict stock market movement direction based on historical data series and a subset of financial indexes as weighted inputs. (15) presented a new prediction model, hybrid of jellyfish and particle swarm optimization techniques (HJPSO-SVM) for financial dataset classification accuracy. This approach efficiently control the excessive amount of data while maximizing the parameters for SVM. The suggested HJPSO-SVM model beats other methods like SVM, Genetic Algorithm-SVM (GA-SVM), Particle Swarm Optimization-SVM (PSO-SVM), and Joint Sparse-SVM (JSSVM). 2.1.1. Deep Learning Approaches (16)employed three distinct deep learning architectures for predicting the prices of NSE-listed companies: convolutional neural networks (CNN)-sliding window model, recurrent neural networks (RNN), and LSTM. These deep learning architectures uncovered the latent dynamics present in the data rather than fitting it to a particular model. (17) presented a unique multi-input LSTM model capable of collecting valuable information from low-correlated variables while eliminating their damaging noise. (18) proposed an associated deep recurrent neural network model with multiple inputs and multiple outputs, which is based on an extended short-term memory network. Simultaneously, the opening price, the lowest price, and the greatest price of a stock were predicted by the associated network model. The network that is affiliated with the model was compared to a deep recurrent neural network model and an LSTM network model. Through the use of extra input gates as well as new variables such as the prices of other connected stocks, the prediction accuracy was boosted significantly. (4) suggested a stock price forecasting method based on CNNLSTM. This method significantly enhanced the accuracy of stock price forecasting by combining the benefits of CNN, and LSTM, where CNN capably extracted effective features from the data, while LSTM detected the most appropriate mode for relevant data and identify the interdependence of data in time series. (19) proposed a new framework for predicting stock prices using two prominent models: RNN, LSTM and Bi-Directional LSTM (BI-LSTM). The findings show that employing RNN models like LSTM and BI-LSTM, along with suitable hyper-parameter tweaking, accurately estimate future stock trends. (20) on the other hand provided a novel stock-market prediction framework (LSTM–Forest) that avoids model overfitting by combining RF and LSTM. In order to increase predictability and profitability and facilitate interpretability, the multi-task model based on RF’s variable importance analysis was developed. This model forecasted the stock market returns and categorized the returns. (21) distinct from other papers, compared the results of two distinct models: a statistical model, Autoregressive Integrated Moving Average (ARIMA) and a deep learning model (LSTM) using a selected set of NASDAQ data. Both algorithms were employed to forecast the average daily or monthly prices of selected NASDAQ-listed companies. (22) proposed an Artificial Neural Networks (ANNs) based Particle Swarm Optimization with Center of Gravity (PSOCoG) model for stock price prediction. This model is an upgraded Particle Swarm Optimization (PSO) algorithm based on the center of gravity concept which helped to identify the optimal hyperparameters for neural networks. The suggested PSOCoG for ANN yields the optimal configuration for the number of hidden layers (NHL), number of neurons per hidden layer (NNPHL), activation function (ACTFUN) type, and learning rate (LR), thus improving the prediction accuracy. (23) predicted the stock market index using the Transformer framework. Unlike a lot of other studies, the model (23) predict the future stock index values, not just price swings. Their transformer’s encoder-decoder architecture predicted the next day’s closing price and compared it to the actual value for evaluation. (24) on the other hand, created a new hybrid neural network for price prediction called the frequency decomposition induced GRU transformer model (FDGRU-transformer or FDGtrans), which used empirical model decomposition to break down the entire ensemble of cluttered data into a trend component as well as several informative and independent mode components for stock price prediction. Although they use GRU and LSTM, they use the proposed network’s ability to represent the influence of varying weights from each of the preceding time step to the present one, hence facilitating the development of a time series model from a more nuanced perspective of prediction. (25) presented a multi-graph convolutional adversarial system for stock price prediction: VGC-GAN. Using historical stock data, the suggested approach created several correlation graphs and built a Generative Adversarial Network (GAN) framework to improve the model’s predictive capability. Then, combining Multi-Graph Convolutional Network (Multi-GCN) and GRU as the generator, this GAN framework analyzed latent correlations between stocks and temporal dependency of stocks to improve prediction accuracy. (26) showed an explainable hybrid quantum neural network that can be used to look into how tweets can affect a stock price forecast. The suggested hybrid genetic algorithm-based quantum neural network used AI techniques to look into the impact of tweets’ average sentiment score and figure out how each attribute contributed to the outcome of the prediction. (27) proposed a stock prediction model using dynamic market correlation
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 642 information (MDF-DMC) together with multi-view stock data features. Their improved Transformer encoder learned the correlation between the stock to be predicted and all the selected stocks in the stock market dynamically and extracted the features of the market correlation by combining multi-view raw data of a single stock with a Multi-layer Perceptron Mixer (MLP-Mixer). 3. Methodology We have developed a thorough framework using deep learning models and ensemble approaches for stock price prediction. The method combines long-short-term memory (LSTM), convolutional neural networks (CNN), LSTM with attention, and hybrid CNN-LSTM models improved by an attention mechanism. Moreover, ensemble techniques have been used to mix the prediction powers of several models for maximum accuracy. Figure 1 Our proposed Ensemble Framework 3.1 Dataset We have chosen 10 companies from the GICS financial sector as our dataset. This dataset was chosen to ensure a varied representation within the financial sector (Table 1). This encompasses diversified banks (e.g., JPMorgan Chase, Citigroup), investment banks (e.g., Goldman Sachs, Morgan Stanley), and asset management firms (e.g., BlackRock), so assuring thorough representation of essential subsectors. Figure 2 shows the price trends for all tickers during the time period. Table 1 Classification and Primary Business Segments of Selected Financial Institutions Ticker Company Classification Primary Business Segments AXP American Express Co. Financial Services Non-Interest Revenue, Interest Revenue BAC Bank of America Corp. Banking Consumer Banking, Global Wealth and Investment Management, Global Banking, Global Markets BLK BlackRock Inc. Investment Management Investment Advisory, Risk Management, and Advisory Services BRK.B Berkshire Hathaway Inc. Conglomerate Insurance, Manufacturing, Distribution, Pilot Travel Centers, Service and Retailing, Energy, Railroad C Citigroup Inc. Banking Global Consumer Banking, Institutional Clients Group, Corporate/Other GS Goldman Sachs Group Inc. Investment Banking Investment Banking, Global Markets, Asset Management, Consumer and Wealth Management JPM JPMorgan Chase and Co. Banking Consumer and Community Banking, Corporate and Investment Bank, Commercial Banking, Asset and Wealth Management. MS Morgan Stanley Investment Banking Institutional Securities, Wealth Management, Investment Management. PNC PNC Financial Services Banking Retail Banking, Corporate and Institutional Banking, Asset Management Group. WFC Wells Fargo and Co. Banking Community Banking, Wholesale Banking, Wealth and Investment Management.
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 643 Figure 2 Stock price trends across all tickers The dataset covers a 14-year period, ranging from 2010 to 2023. We have the OHLCV (Open, High, Low, Close, Volume) core features as well as adjusted close, and trading volume. Additional features include daily returns, cumulative returns, and a range of technical indicators: Simple and Exponential Moving Averages over 20, 50, and 200-day windows, 20-day volatility, 14-day Relative Strength Index (RSI), Commodity Channel Index (CCI), Doji candlestick patterns, and Bollinger Bands (upper and lower bounds). These features enable both trend and momentum-based modeling for financial forecasting, totaling 20 features. 3.2 Data Preprocessing As data preparation is essential for preparing the dataset for training predictive models, we have used different techniquesfrom filling missing values to scaling. The technical indicators show missing values, notably in moving averages (SMA and EMA) for longer windows, as seen in Figure 2. Figure 3 Missing values in the dataset We have used Zero imputation, forwardand backward-fill techniques for these missing variables. Also, MinMax scaling has been applied to standardize input features such that every feature falls within a consistent range, therefore permitting model training:
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 644 t=L t=1 t=1 t=1 𝑥𝑠𝑐𝑎𝑙𝑒𝑑 = 𝑥 − 𝑚𝑖𝑛(𝑥) 𝑚𝑎𝑥(𝑥) − 𝑚𝑖𝑛(𝑥) Separately scaling the target variable (Close price) helps to enable inverse conversions during evaluation. 3.3 Sequence Creation Sequential data has been generated for time-series modeling by use of a rolling window technique. The following formulation shows generated input sequences Xt and target variables yt with a fixed sequence length L. 𝑋𝑡 = [𝑥𝑡 − 𝐿, 𝑥𝑡 − 𝐿 + 1, . . . , 𝑥𝑡 − 1], 𝑦𝑡 = 𝑥𝑡 Algorithm 1 outlines the sequence creation process. Algorithm 1 Sequence Creation for Time-Series Data Input: Scaled dataset D = {x1, x2, . . . , xN }, sequence length L Output: Input-output pairs {(Xt, yt)}N−1 for t = L to N − 1 do Construct the input sequence: Xt = [xt−L, xt−L+1, . . . , xt−1] Define the target variable: yt = xt r eturn {(Xt, yt)}N−1 t=L 3.4 Model Development Several deep learning models have been designed and tested to forecast stock prices. 3.4.1 LSTM Model LSTM model has helped to derive long-term dependencies in time-series data. The model architecture consists in stack LSTM layers, dropout layers for regularizing, and dense layers for last output prediction. Algorithm 2 presents a method wherein Backpropagation Through Time (BPTT) maximizes the model parameters. Algorithm 2 LSTM Model Training Input: Training data {(Xt, yt)}M , learning rate η, epochs E Output: Trained LSTM parameters θ Initialize LSTM parameters θ for epoch e = 1 to E do for each minibatch B ⊆ {(Xt, yt)}M do Compute loss and update parameters using BPTT return θ 3.4.2 LSTM with Attention Mechanism We included an attention mechanism to increase the prediction capacity of the LSTM model. This method provides every latent state of the LSTM weights, therefore allowing the model to focus on the most relevant time steps. Great detail on the LSTM with attention training method is provided by algorithm 3. Algorithm 3 LSTM with Attention Training Input: Training data {(Xt, yt)}M , learning rate η, epochs E Output: Trained parameters θ Initialize LSTM and attention parameters θ for epoch e = 1 to E do Compute attention weights and context vector Make prediction and update parameters return θ 3.4.3 CNN Model The Convolution Neural Network (CNN) model we used in this paper helps to derive local temporal patterns from the input sequences. This model effectively records short-term dependencies and trends by way of convolutional filters and pooling layers. Emphasizing the decrease of prediction errors, the training approach of the CNN model follows the LSTM model.
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 645 4. Results Both the Stack Ensemble Model and the Weighted Ensemble models were assessed in four timespans: 90 days, 180 days, 360 days and 5 years. Using key performance indicators like RMSE, MAE, MAPE, and R2 score, we investigated and contrasted their efficacy. Because of its dynamic weighting mechanism and flexibility to complicated market patterns, the results show the Stack Ensemble Model’s better performance over all time spans and measures. 4.1 Performance Overview The Weighted Ensemble Model aggregates fixed weight predictions from several base models. This method lacks adaptability, especially in volatile or long-term situations, even if it is simple and computationally efficient. By means of a meta-learner, the Stack Ensemble Model dynamically modulates the contributions of base models depending on their relevance to the data. This enables the Stack Ensemble to more successfully capture both long-term dependencies and short-term fluctuations, hence generating routinely better performance across all measurements. Table 3 Compares the models based on RMSE, MAE, MAPE, and R2-Score. The results indicate that the Stack Ensemble consistently outperforms the Weighted Ensemble in all metrics, highlighting its adaptability and precision Table 3 Comparison of Weighted Ensemble Model and Stack Ensemble Model metrics across different time spans Timeline Model Average RMSE Average MAE Average MAPE Average R2 Score 5 Years Weighted 6.8322 5.4761 0.0291 0.7485 Stack 0.0329 0.0273 0.0479 0.7591 360 Days Weighted 8.4696 6.8681 0.0305 0.8623 Stack 0.0353 0.0286 0.0417 0.8733 180 Days Weighted 8.8050 7.3050 0.0336 0.8330 Stack 0.0383 0.0311 0.0442 0.8522 90 Days Weighted 8.9043 7.4013 0.0316 0.8335 Stack 0.0414 0.0340 0.0477 0.8130 The outcome exposes a clear difference between the two models. For example, the Stack Ensemble had a far lower RMSE of 0.0329 whereas the Weighted Ensemble noted an RMSE of 6.8322 throughout the five-year period. This significant discrepancy emphasizes the incapacity of the Weighted Ensemble to extend over long times since its constant weights cannot efficiently manage the dynamic and volatile character of long-term stock price fluctuations. By constantly changing its weights, the Stack Ensemble reduces significant errors by giving base models better suited for capturing long-term trends top priority. Table 4 Comparison of Weighted Ensemble and Stack Ensemble Model Metrics for all Tickers Ticker Model RMSE MAE MAPE R2 Score AXP Weighted 4.7991 3.6523 0.0230 0.8190 Stack 0.0354 0.0288 0.0390 0.7429 BAC Weighted 0.9447 0.7285 0.0236 0.9111 Stack 0.0245 0.0193 0.0322 0.8821 BLK Weighted 27.9659 21.8064 0.0313 0.7088 Stack 0.0285 0.0236 0.0373 0.7899 BRKB Weighted 9.6002 8.2295 0.0248 0.8768 Stack 0.0245 0.0204 0.0242 0.9253
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 646 C Weighted 3.5576 3.3499 0.0734 - 0.1368 Stack 0.0458 0.0412 0.1098 0.3491 GS Weighted 9.7180 7.6607 0.0226 0.8068 Stack 0.0363 0.0298 0.0399 0.6952 JPM Weighted 3.3043 2.6214 0.0192 0.9376 Stack 0.0252 0.0208 0.0281 0.9252 MS Weighted 2.8271 2.1909 0.0249 0.7856 Stack 0.0322 0.0259 0.0326 0.7417 PNC Weighted 4.3983 3.5698 0.0260 0.9403 Stack 0.0420 0.0350 0.0740 0.8167 WFC Weighted 1.2070 0.9513 0.0219 0.8355 Stack 0.0350 0.0282 0.0615 0.7225 Over all time, the Stack Ensemble routinely beat the Weighted Ensemble. For example, the Stack Ensemble noted far lower MAE of 0.0414 whereas the Weighted Ensemble reported an MAE of 7.4013 throughout the 90-day period. This shows how precisely the Stack Ensemble can manage minor stock price variations. Its meta-learning method helps it to dynamically mix the strengths of its basic models, hence lowering prediction bias and raising general accuracy. With its fixed weighting, the Weighted Ensemble finds it difficult to adjust to minute changes in stock price, which increases mistake rates. Stack Ensemble routinely obtained lower MAPE values such as 0.0479 throughout the five-year period—than the Weighted Ensemble’s 0.0291. The lower MAPE of the Stack Ensemble throughout all time spans indicates its ability to adapt to various market conditions, thereby precisely projecting stock prices even in very turbulent periods. This flexibility is necessary for financial forecasting, in which market dynamics may change rapidly. Over the time periods, the Stack Ensemble model obtained noticeably higher R2 scores. For instance, the Stack Ensemble achieved a R2 score of 0.9478, whereas the Weighted Ensemble scored 0.8623 in the 360-day period. This demonstrates the Stack Ensemble’s ability to capture intricate data linkages involving both long-term and short-term dependence. Especially in ever more complex circumstances, the Weighted Ensemble’s lower R2 scores highlight its limited ability to accept variance. 4.2 Analysis across different time spans In the 90-day period, for example, the Stack Ensemble recorded an RMSE of 0.0414 and an MAE of 0.0340, far better than the Weighted Ensemble, which had an RMSE of 8.9043 and an MAE of 7.4013. The Stack Ensemble is especially good in catching short-term swings since it can dynamically prioritize current trends. With its constant weighting, the Weighted Ensemble found it difficult to adjust to fast changes in the market and so produced more errors. The Stack Ensemble kept proving better across medium-term spans. With an RMSE of 0.0353 and a R2 score of 0.9478 it demonstrated its capacity to properly manage modest degrees of variability. Showing clear performance decline, the Weighted Ensemble had an RMSE of 8.4696 and a R2 score of 0.8623. Combining the dynamic weighting mechanism of the Stack Ensemble with its use of several base models helps it to capture both local trends and more general market patterns, therefore strengthening it in medium-term prediction. With its biggest errors in this range, the Weighted Ensemble Model found long-term forecasts most difficult. The RMSE of 6.8322 and R2 score of 0.7485 show its incapacity to extend over long times. Its static character makes it difficult for it to provide basic models better suited for long-term dependency top priority. By comparison, the Stack Ensemble proved to be quite resilient and flexible, with a very low RMSE of 0.0329 and a high R2 score of 0.8581. Its dynamic meta-learning method lets it use long-term trend-oriented base models including attention-based LSTMs. The dynamic weighting method of the Stack Ensemble explains its exceptional performance since it best integrates forecasts from several base models. Unlike the Weighted Ensemble, which gives each base model fixed weights, the Stack Ensemble dynamically adjusts weights depending on data features using a meta-learner. This helps it to select
World Journal of Advanced Research and Reviews, 2025, 27(03), 639–650 647 models more relevant for specific time periods or market conditions, therefore improving accuracy and reducing error. Among other foundation models, the Stack Ensemble also aggregates CNNs, LSTMs, and hybrid attention-based architectures. From long-term patterns to fleeting fluctuations, this diversity lets it document a wide spectrum of dependencies. Attention mechanisms help to improve its resilience and interpretability by further enhancing its capacity to concentrate on the most pertinent timesteps. 5. Discussion The results of this experiment reveal, more specifically the Stack Ensemble Model, the efficiency of sophisticated ensemble learning techniques for stock price prediction over different time periods. Dynamic capturing of both long-term trends and short-term fluctuations in stock values was made possible by deep learning models comprising hybrid CNNLSTM architectures and LSTM with attention mechanisms added into the Stack Ensemble. Through dynamic weighting and meta-learning, the Stack Ensemble’s persistent excellence over measures including RMSE, MAE, MAPE, and R2 score underlines its capacity to adapt to difficult and volatile market conditions. On the contrary, although being computationally efficient and simpler, the Weighted Ensemble Model suffered with greater mistakes in situations requiring long-term interdependence or short-term volatility. Its stationary character in giving set weights to base models proven to be a restriction in dynamic market situations, where successful predictions depend on flexibility and adaptation. The results confirm the need of using sophisticated methods able to dynamically balance contributions from several models catered to certain market conditions. The creative integration of attention processes by the Stack Ensemble improves interpretability by means of identification and prioritizing of the most pertinent timesteps in historical data. This offers more insights into market movements, so enhancing not just the forecasts but also the awareness of the fundamental trends. 5.1. Future Direction • Building on the achievements of this project, we believe there are several directions for future research • Analyzing the scalability of the model in handling more large datasets or more frequent data would be a good way to test the efficiency of the model. • Using explainable Artificial Intelligence (XAI) techniques can help to make the model more open and understandable. AI's growing momentum in finance, when paired with XAI, reflects a shift toward more transparent, responsible, and interpretable decision-making (28). • Employing a wider spectrum of features would help explore more avenues. Also, including mood analysis from financial news and social media or outside macroeconomic factors, like inflation data, would help to increase prediction accuracy. • Testing creative feature engineering ideas, including embedding representations for technical indicators, could improve model inputs and general performance. • Including financial assets, such as commodities, foreign currencies, and cryptocurrencies, would test the generalizability of the models. • Applying federated learning methods helps to aggregate data from many sources without direct data exchange, therefore enabling distributed and privacy-preserving stock prediction. • A real-time prediction system can assist in making the solution more realistic for either high-frequency trading or portfolio management by always changing model predictions depending on actual stock data. 6. Conclusion This research presents a novel ensemble model for stock price prediction that uses the Optimized Weighted Ensemble framework and the Stacking Ensemble Meta-Model to overcome the limitations of the single-model methods. These models can collectively reshape how hybrid machine learning models can be used to provide robust, scalable, and accurate financial forecasts. The Optimized Weighted Ensemble framework uses limited optimization approaches to generate optimal weights for aggregating predictions from various models, such as LSTM, CNN, and a Hybrid CNNLSTM-Attention architecture. This technique reduces error metrics while enforcing critical restrictions. Such restrictions assure not only a theoretically valid optimization process, but also a balanced and dependable ensemble that efficiently leverages the distinct capabilities of each constituent model. This approach is extremely versatile, producing consistent process forecasts across different stock tickers, regardless of individual model biases or shortcomings. Additionally, the Stacking Ensemble Meta-Model uses a linear regression meta-model to construct a second layer of prediction by aggregating base model predictions as meta-features, thus improving the framework’s predictive strength and generalizability. . This method of letting the meta-model include supplementary insights and