© 2025 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).
OPEN ACCESS
Accurately forecasting stock prices remains a major challenge due to the uncertainty of market movements. Improving prediction accuracy can help investors reduce risks and make more informed decisions. Although machine learning has been widely applied to financial forecasting, limited research has focused on the Saudi stock market despite its size and economic importance. This study develops and evaluates an ensemble-based forecasting model for three major Saudi companies: Al-Rajhi, SABIC, and STC. The methodology applies machine learning and data mining techniques using an Artificial Neural Network (ANN), Support Vector Regression (SVR), and a voting ensemble that integrates their predictions. Optimal window sizes and hyperparameters are determined through a grid-search tuning procedure combined with k-fold cross-validation, and the final performance is assessed using an 80:20 holdout partition. Baseline comparisons using the individual ANN and SVR models are included to contextualize the performance of the ensemble. The results show that the voting ensemble achieves lower RMSE values than the individual models, with RMSE scores of 1.0042 for Al-Rajhi, 2.1549 for SABIC, and 1.3163 for STC when using a two-day input window. These findings indicate that combining the strengths of ANN and SVR enhances forecasting accuracy across multiple datasets. The study demonstrates the effectiveness of ensemble learning for Saudi stock market prediction and highlights the potential for improved decision-making in financial analysis. Future research may extend this work to additional companies, alternative ensemble strategies, and real-time forecasting environments.
Saudi stocks market, stock price forecasting, hyperparameter optimization, ensemble learning
In recent years, the need for utilizing stored data has become critical due to the increasing volume of stored data among several sectors. Data mining is one of the methods that has been frequently used in order to gain insight and discover hidden patterns and trends from stored data [1]. Recently, researchers have shown an increased interest in applying data mining techniques in different fields, including Medical [2], Financial [3], Education [4] and Engineering [5]. Over the past years, stock market prediction has been one of the main research areas due to its remarkable importance in analyzing stock market trends and prices.
Stock market is the place where investors sell and purchase shares of public companies [6]. The stock market plays an important role in the economic growth of countries. Millions of people trade in various financial markets every day. As a result, many of the researchers and investors became interested in proposing different methods to forecast the price or trend of the stocks in the stock market [7]. Investment in the stock market poses several risks and challenges in terms of earning or losing money. In addition, fluctuations in the stock market affect the profit of the investor. It has been noticed that, in the last few years, the Saudi stock market data had not been analyzed in order to predict the share prices based on historical data. Therefore, building a model for forecasting the price of stocks in the stock market will encourage more people to gain enthusiasm and confidence in investing their money in the stock market.
The main goal of the proposed work is to build a forecasting model for the Saudi stock market that predicts the next day's closing price. The prediction model will use a time series for the stock market closing price. The popular stocks in the Saudi stock market, which will be considered in this study, include: SABIC, Al-Rajhi, and STC. In this study, the Artificial Neural Network (ANN), Support Vector Machine (SVM) and voting algorithms are applied with the aim of increasing the performance and predicting the closing price based on previous closing prices. The proposed model was built by considering the optimal window size and implementing parameter optimization. It has been observed that ANN is widely applied in the field of stock market forecasting as it shows promising results [8, 9]. Also, the SVM is applied in various significant fields and provides better performance and efficient work [10, 11]. The main characteristic of a voting algorithm is combined multiple classifiers to enhance the prediction and increase the performance [12]. One of the study's goals is to propose a high-performance model that fits the three datasets of the stock market and predicts the closing price based on two past closing prices. This work will evaluate various machine learning algorithms, including the ANN, SVM and voting ensemble by using WEKA tool. Furthermore, voting ensemble method has a better result than the ANN and SVM algorithms as it fits any of the three companies’ datasets and it enhances the accuracy of the proposed model where it achieves 1.0042, 2.1549, and 1.3163 RMSE for Al-Rajhi, SABIC, and STC, respectively, when using 80:20 holdout technique.
Many machine learning approaches have been proposed for stock market prediction; most prior work either focuses on non-Saudi markets, examines a single stock or index, or evaluates one specific algorithm without systematic parameter tuning or cross-company validation. Consequently, it remains unclear whether a single, well-tuned model can generalize across different Saudi companies while maintaining high predictive accuracy.
To fill this gap, the present study develops and empirically evaluates an ensemble learning framework based on ANN and SVM in regression mode, combined through a voting ensemble. The main contributions of this work are: (i) constructing a unified forecasting model for three major Saudi companies (SABIC, Al-Rajhi and STC) using the same modelling pipeline; (ii) investigating the effect of window size and parameter optimization on the performance of ANN and SVM for Saudi stock data; and (iii) demonstrating that the resulting voting ensemble achieves lower prediction error than the individual models and can be applied as a generalized model across different Saudi stock datasets.
The remaining part is arranged as follows: the related work that has been done before is addressed in Section 2. The proposed techniques that were used in this study are described in Section 3. The experiment part is carried out in Section 4. The investigation of the feature selection and the results is addressed in Section 5. Finally, Section 6 presents the conclusion and the recommendation.
Recently, forecasting the price and stock market trends has received a lot of interest from many researchers. This section presents a summary of the previous works that have been published within the last five years in the field of stock market prediction. The literature reviews presented in this section have been organized in chronological order.
AlQasrawi et al. [13] introduced a hybrid model combining Multilayer Perceptron Neural Networks (MLPNNs) with Genetic Algorithms (GAs) to predict Palestinian stock market values. The model was applied to forecast stock prices for the three largest Palestinian companies. By optimizing neural network weights with GAs, the model effectively handles stock data's volatile and nonlinear nature. The proposed MLPNNs-GAs model outperformed traditional methods, achieving Mean Square Error (MSE) values of 0.0011 for the Al-Quds Index, 0.0021 for the Bank of Palestine, 0.001 for Palte, and 0.0006 for Padico. It offers reliable predictions, making it a valuable tool for investors in forecasting financial time series data.
Alotaibi [14] aimed to predict the Saudi stock market using various variables, such as opening, lowest, highest, and closing prices. The project produced projected closing prices for the next exponential smoothing (ES) was used to clean data obtained from the Saudi Stock Exchange, known as Tadawul. A multivariate Long Short-Term Memory-Deep Learning (LSTM-DL) algorithm was utilized to predict stock market prices. The proposed multivariate LSTM-DL model achieved prediction rates of 97.49% and 92.19% for the univariate model, demonstrating its effectiveness in forecasting stock market prices. These results also emphasize the accuracy of DL and the benefits of integrating multiple information sources for stock market prediction.
Nabipour et al. [15] applied different machine learning and DL algorithms to predict stock market movement. Two DL algorithms were applied, which are Recurrent Neural Network (RNN) and Long Short-Term Memory (LSTM). Furthermore, nine machine learning algorithms were used to build the forecasting model, which are Decision Tree (DT), Random Forest (RF), Adaptive Boosting (Adaboost), eXtreme Gradient Boosting (XGBoost), Support Vector Classifier (SVC), Naïve Bayes (NB), K-Nearest Neighbors (KNN), Logistic Regression and ANN. The ten-year data for four stock market groups in Tehran were collected from tsetmc.com. The authors used two approaches for the input data. In the first approach, continuous input was used. However, in the second approach, a new step was considered to convert the continuous data into binary data. The dataset was partitioned in the ratio of 70:30. They found that the second approach got the highest average accuracy, which is around 90% with RNN and LTSM algorithms.
Moghar and Hamiche [16] proposed a DL model using the LSTM (a variant of RNN) method to predict the future opening price for the stock market. The data has been collected from Yahoo Finance of two stocks, which are GOOGL and NKE. The GOOGL stock data included 16 years of daily opening price, whereas NKE stock data included 9 years only. The model divided the data as 80:20 for training and testing phase. The authors evaluated a model performance by using different epochs. They found that the performance of the model will be increased if more epochs were added.
Sarode et al. [17] applied a model that comprises the prediction of stock price based on historical and news analysis. In the prediction phase, they used LSTM to forecast the price of stocks based on historical data. The data for the prediction stock collected from the National Stock Exchange (NSE) was for a major Indian stock exchange. The authors identified that the features of historical trade details and market indices movement are important to predict the price of stocks for various companies. Whereas in the news analysis phase, they collected news from the business news websites then analyzed the sentiment of stock companies. The prediction price with news analysis is integrated to give recommendations on the rise of future prices.
Pahwa and Agarwa [18] used supervised machine learning algorithms to predict the future closing stock market price. They applied a Linear Regression (LR) method on the data that was collected from Quandl.com, which is a platform for financial and economic data. They used around 13 years of data for the Google stock price. The dataset contains different attributes, including close, open, low and high prices. Authors considered the percentage change for the low and high prices as well as the percentage change for the opening and closing prices. The prediction model achieved around 97.671% accuracy.
Zhong and Enke [19] predicted a daily return in the stock market using hybrid machine learning techniques. They used the stock market data for ten years (2518 samples) with 60 features, and they applied several preprocessing techniques to improve the quality of raw data. Moreover, the authors tested three data sets: an untransformed dataset, and two transformed datasets via principal component analysis (PCA). In this model, the researchers used deep neural network (DNN) and ANN classifiers. They achieved the highest accuracy and scored around 60.1 (0.3011) mean squared error (MSE), using DNN with the transformed data.
Moreover, a new method called AutoSLSTM was proposed by Al-Thelaya et al. [20] that uses a combination of two DL algorithms, which are an LSTM autoencoder and a stacked LSTM to forecast Bahrain stock market. Ten years of stored data from Bahrain Bourse All Share Index (BAX) were used to build the prediction model. The authors used the ten days' closing price data to predict the close price for the 1st, 5th and 10th day in the future. Authors found out that the LSTM and AutoSLSTM outperform the Multilayer Perceptron (MLP) for stock market prediction. The proposed algorithm scored 6.125, 16.916, and 22.463 Root Mean Square Error (RMSE) to predict the 1st, 5th and 10th future day stock market, respectively.
Ojo et al. [21] predicted the future state of the stock market using the Multivariate time series model. They studied ten years of data for the NASDAQ Composite stock market index. They used 90% of the data for the training phase, and 10% were used for testing and validation phases. The researchers applied a stacked LSTM network on the dataset. The result of this model scored a 53.6% accuracy.
Sachdeva et al. [3] proposed a model to forecast the stock market price for the Indian stock market. They collected stock market data for ten years, containing many features: date, opening, high, low, and close prices. The authors applied normalization techniques for the data. Moreover, they used the RNN and compared two optimizers, Adam and RMSprop, to predict the stock price. The authors tested different time steps and different numbers of LSTM layers to find the best model. RNN gave better accuracy, which was 97.64% with RMSprop optimizer using one LSTM layers, and 60 time-steps.
In addition, Ghani et al. [6] applied LR, which is a machine learning algorithm, in order to predict the stock market closing price. Date and closing price are the two input attributes that are considered to build the prediction model. Eight months of Amazon (AMZN) and Apple (AAPL) stock market datasets were collected from Yahoo Finance. The authors applied different approaches to increase the performance of the prediction model. In the first approach, authors considered the date and the closing price to predict future closing price, by using LR algorithm and 8 months samples. This model achieved a 24.31 average absolute error. Another method has been applied which used the average of the previous three days to predict the closing price for the next day. This model achieved an average absolute error value of 21.08. An average absolute error value of 16.62 is the best result that was obtained by applying LR with ES measurements method. Finally, the authors found that the greater number of samples leads to a more accurate prediction. Also, they found that the LR with ES got less error and higher accuracy compared to other approaches.
Furthermore, Wang et al. [22] made a novel framework collecting three different data types to predict the stock market’s direction. In this work, the Chinese stock market dataset was collected during 345 trading days. Also, they focused on using logistic regression for prediction of the stock market. The results demonstrated that the logistic regression achieved better than the SVM algorithm in terms of accuracy of three phases in this model.
Rustam and Kintandani [23] applied a machine learning algorithm, which is Support Vector Regression (SVR) with Particle Swarm Optimization (PSO), to forecast the stock price. The PSO is responsible for selecting the technical indicators in this model. They carried out the model on the dataset of the Jakarta Composite Index (JKSE) and the real estate stock in Indonesia. They used data that contained 650 datasets for 8 months. The dataset is divided into a training set and a testing set to carry out the algorithm. The experiment showed that the machine learning model has good performance with less Normalized Mean Squared Error (NMSE) values that are below 0.1.
Kumar et al. [24] applied various machine learning algorithms which are SVR, RF, KNN, and Naive Bayes (NB), to predict the stock market price. They tested two datasets on the Indian stock market, one with a small number of samples and the other with a large number of samples. They extracted the features for the data by calculating several technical indicators. The data was split into a training and a testing set with 70:30 ratio to apply machine learning techniques. The authors used a time window of size 90 for the stock market prediction model. They found that the RF algorithm achieved better accuracy in the small dataset, which is 55.80%, while Naive Bayesian achieved better accuracy with the large dataset which is 70.80%.
Ebadati and Mortazavi [25] studied an integrated system of ANN algorithm and GA to predict stock price and time series based on the history of stock prices. The system used GA to identify the weights of the ANN technique. The experiment was carried out on five companies' datasets, which are Apple, Pepsi, IBM, McDonald's, and LG from the NASDAQ. The analysis of the stocks was applied to a 200-day main index. The authors made a comparison between the hybrid model with Back Propagation (BP) algorithms and without BP algorithms. The experimental results revealed that an integration model of GA and BP algorithms in Apple stocks obtained 99.99% in terms of sum square error (SSE) and 90.66% in terms of time consumption.
Yousif and Elfaki [8] studied a comparison between two models, which are linear time series algorithms and nonlinear ANN algorithm for predicting Doha stock market. The linear time series algorithms used in this study are the Quadratic trend model, double exponential smoothing model, and Autoregressive Integrated Moving Average (ARIMA). The dataset was gathered from the Qatar exchange and was split into two parts. The first part was used for identifying an appropriate time series model and the second were used for testing the model. However, the results obtained with the ANN achieved 3.01 RMSE, which is outperformed compared with linear time series algorithms.
Furthermore, Usmani et al. [26] built a forecasting model to predict stock market performance of Karachi Stock Exchange (KSE). The authors applied SVM and three types of ANN, which are Single Layer Perceptron (SLP), Multi-Layer Perceptron (MLP) and Radial Basis Function (RBF). This study considered various factors that could influence the stock market, such as News, Twitter feeds and historical data, in order to predict the market’s behavior positively or negatively. Authors found that the oil rates attribute is the most influential factor on the market behavior. Moreover, they found that MLP got the highest accuracy which is 77% with the testing set.
In conclusion, a lot of research has been published in the area of predicting stock market price. Various machine learning and DL techniques were applied to predict the future price and trends. Classification and regression techniques were applied to forecast the stock market trends whether it’s up/positive or down/negative or to predict the next day's price. From the previous works, it has been found that there is a limited number of research conducted on the Saudi stock market, which indicates that there is a need to study this market. Moreover, ANN is widely used in the area of stock market prediction as it shows good results [8, 25]. We observed that the previous research has never examined the use of ensemble method for building the stock market forecasting model. In addition, most of the previous work developed a model for each stock market dataset instead of using a single model that fits any of stock market datasets.
This section demonstrates the machine learning algorithms that have been used to develop the proposed model to forecast the Saudi stock market price, including the ANN, SVM, and Ensemble (voting) techniques.
3.1 Artificial Neural Network
The ANN algorithm is one of the most common algorithms for machine learning. It is simulated from the human brain structure. The neural network includes multiple neurons, which are the core processing units of the neural network, in a multi-layered network. The neurons of neural networks are organized into layers so that each level is linked to the one above and below. Inputs from an external entity are received by the first layer, named the input layer. The last layer is named the output layer, where the final output is presented. Hidden layers are the layers in between that could include any number of layers [27, 28].
When data is available for processing by the ANN algorithm, it is filled into the input layer and then passed to one or more hidden layers through channels. Each of these channels have a certain weight assigned to it. The inputs are multiplied to the relevant weights; then the sum is sent to the hidden layer as an input. The neurons of the hidden layer have Bias, which is a numerical value, and it is totaled into the input sum. The generated values are passed through the activation function; the effects of the activation function will determine whether the particular neuron is activated or not. The data of activated neurons will be transferred through the channels to the next layer of neurons [27, 28]. The data would therefore propagate across the network and this is known as forward propagation. The function that computes the result of output layer is [29]:
$Y_{j k}=F_k\left(\sum_{i=1}^{N_{k-1}} W_{i j k} Y_{i(k-1)}+\beta_{j k}\right)$ (1)
In the training mode, the output results from the neural network are compared with the actual results to recognize the errors in the system. To reduce the errors, the data is transferred backward over the network while fixing the weights, this process is called back-propagation. Furthermore, there are various architectures of neural network that are used, but the multi-layer back-propagation architecture is the most utilized [27]. Figure 1 shows the architecture of multi-layer ANN.
Figure 1. Architecture of multi-layer ANN (adapted with modification from a previous study [28])
3.2 Support Vector Machine
SVM is a supervised machine learning algorithm developed in 1992 by Vapnik and co-workers based on the statistical learning theory, as presented in a previous study [30]. It was used originally to solve the classification task. However, this algorithm nowadays has been extended to solve the regression task as well. In the regression task, the output of the model is a continuous value rather than a limited set of values (classes) [30].
The general concept of SVM is to create the hyperplane that divides the data into classes. SVM aims to represent the optimal hyperplane with a support vector to achieve the maximum margin separating the hyperplane. The SVM was improved to be more generalized in order to deal with the regression task, usually called SVR. With only a few variations, SVR has a similar concept to SVM for classification. SVR solves the regression task by determining a convex ε-insensitive loss function that aims to minimize the flattest tube, which includes most of the training objects. Therefore, the multi-objective function has been built from this loss function and the tube's geometrical properties [31]. Figure 2 shows the geometrical perspective of the SVR with a one-dimensional example.
Figure 2. One-dimensional linear SVR (adapted with modification from a previous study [30])
Suppose we have a set of training data $\left\{\left(x_1, y_1\right) \ldots,\left(x_n, y_n\right)\right\}$ with length N, the input $\mathrm{x}=\left\{x_1, \ldots \ldots, x_n\right\}$ and the output is $\mathrm{y}=\left\{y_1, \ldots . ., y_n\right\}$. The objective of SVR is to get the function f(x) that achieves the lowest error ε for all data.
The following formula can determine the primary SVR:
$minimise \frac{1}{2}\|w\|^2+C \sum_{i=1}^N \xi_i+\xi_i^*$ (2)
Subject to:
$y_i-w^T \varphi\left(x_i\right) \leq \varepsilon+\xi_i^* \quad i=1 \ldots N$ (3)
$\begin{gathered}w^T \varphi\left(x_i\right)-y_i \leq \varepsilon+\xi_i \quad i=1 \ldots N \\ \xi_i, \xi_i^* \geq 0\end{gathered}$ (4)
$\xi_i$ and $\xi_i^*$ are slack variables used to avoid outlier by determining how many points can be tolerated outside the tube. The constant C > 0 is a tunable parameter to minimize the error. Where w is a weight vector and ||w|| is the magnitude of the normal vector to the surface that is being approximated. $\varphi$ is the transformation from data space to kernel space.
The function for the continuous value can be written as:
$y=f(x)=\sum_{j=1}^N\left(\alpha_i^*-\alpha_i\right)\left(\varphi\left(x_i\right) \cdot \varphi(x)\right)$ (5)
where, $\left(\varphi\left(x_i\right) \cdot \varphi(x)\right)$ is the Kernel function that helps to improve the accuracy by mapping the data into a higherdimensional space. Whereas $\alpha_i^*$ and $\alpha_i$ are the Lagrange multipliers.
3.3 Ensemble (voting)
When applying machine learning techniques to solve any problem, the experiment goes through an assessment of many models, then selects one of these models as the final solution. On the other hand, applying different classifiers at the same time to solve the problem has the potential of improving performance. Multiple classifier systems, also called ensemble systems, have gained increased attention in the machine learning community over the last two decades. The ensemble approach aims to combine multiple machine learning models that aims to improve predictive performance and increase efficiency [32]. There are many ensemble methods, including voting, bagging, boosting, and stacking. This study applied the voting method to train the model based on several learners used in the training phase. In the testing phase, each learner makes their own prediction. A mechanism will be applied to combine the individual learners' results, as shown in Figure 3. This mechanism is known as "Combination rules," which depends on the prediction problem, whether it is a classification task or a regression task [12]. This paper applied the voting approach to obtain the most suitable model for forecasting the Saudi stock market price by combining several optimal models to produce a single model for three Saudi stock market companies.
Figure 3. Ensemble learning (voting)
4.1 Description of dataset
The Saudi Daily Stocks History dataset from Tadawul [33] will be used in this study. The dataset is collected by using Selenium on Python. The information represented by the dataset is about daily trends (opening, closing, change, date, high, low, change_percent, volume_traded, value_traded_SAR, number_trades). The data is collected at various points in time, which is called "time-series data". Three of the most popular Saudi stock market companies and the most active stocks are targeted in this study, which are: SABIC, STC and Al-Rajhi. STC was chosen because it is the most famous local telecommunications company in Saudi Arabia; while SABIC was used in this study due to it being the largest petrochemical industry in the world, and it is one of the most famous companies in Saudi Arabia. Similarly, AL Rajhi bank is one of the largest banks in that Saudi financial sector. The collected data of the Saudi stock market companies (SABIC and Al-Rajhi) contains about 4769 and 4708 records respectively, which represent market data from December 2001 to March 2020. While the data collected of STC’s stock market contains about 4443 records that represent market data from January 2003 until March 2020.
In this study, some pre-processing was performed on the collected data in order to construct the proposed model. It has been noticed that the collected data for the Saudi stock market during the years before 2006 recorded stock prices for six days a week. Whereas the years after 2006 recorded stock prices for five days a week only. As a result, some records have been removed bringing the total number of records to 3487 for the dates between 15th April 2006 and 19th March 2020 for both STC and SABIC. While Al-Rajhi dataset turned out to be 3457 records for the same period.
In addition, irrelevant attributes, including opening, change, high, low, change_percent, volume_traded, value_traded_SAR, and number_trade, were eliminated. Moreover, for the window application, some variables have been created like Xn, where n $\in$ {1,2,3,4,5}, that represent the stock price n days before. Thus, the three datasets contain the target attribute (Close), which is a continuous-valued attribute, and six independent variables, including Date, X1, X2, X3, X4 and X5; as shown in Table 1.
Table 1. Dataset's features and descriptions
|
Feature |
Description |
|
Date |
Represents the date in 'dd/mm/yyyy' format (Date). |
|
X1 |
Represents the stock price five days before (Numeric). |
|
X2 |
Represents the stock price four days before (Numeric). |
|
X3 |
Represents the stock price three days before (Numeric). |
|
X4 |
Represents the stock price two days before (Numeric). |
|
X5 |
Represents the stock price one days before (Numeric). |
|
Close |
The target attribute for the predicted closing price (Numeric). |
4.2 Experimental setup
This paper used WEKA tool to carry out the experimental part of the proposed prediction model. WEKA is a machine learning and data mining tool written in java programming language [34]. The MLP is used for ANN, LibSVM is used for SVM and Vote is used for the Ensemble (voting) in order to build the forecasting model for Saudi stock market price. To construct and validate the prediction model, the Saudi stock market datasets were partitioned into training and testing sets using 80:20 holdout and 10-fold cross-validation techniques.
Figure 4. The proposed model workflow
The experiment went through many stages, as shown in Figure 4:
Stage 1: Holdout and k-fold cross-validation techniques were used to set the SVM’s and ANN’s optimal parameters for each stock market dataset. Both techniques have many parameters that affect the model's performance. In each trial, we try to tune in these parameters to build the most suitable model for each dataset. From the output of this stage, we obtained four models from each dataset. For example, for Al-Rajhi dataset, two models were generated by setting the optimal parameters for SVM based on both partitions and two models were generated by setting the optimal parameters for ANN based on both partition methods. Therefore, twelve models will be generated for the three Saudi stock market datasets. The optimization strategy will be discussed in Section 4.3.
Stage 2: The output of the previous stage will be combined by using voting ensemble method as mentioned in Section 4.4.
Stage 3: The search for the optimal window size will be applied on the voting ensemble model to choose the best size of the window, which refers to the number of previous days that have been used to forecast the next day's closing price, as discussed in Section 5.
4.3 Optimization strategy
To reach the best possible results in the experiment, the search for the optimum parameter values is applied. In the process of searching for the best parameter, the optimal value of a parameter is selected and saved; then, the search process for the next parameter is applied. In this study, the parameter tuning was carried out through systematic manual trials over predefined ranges of the main hyperparameters for each model. For each parameter setting, the model was trained and evaluated using 10-fold cross-validation on the training portion of the data, and the Root Mean Squared Error (RMSE) was recorded. The configuration that achieved the lowest RMSE was selected as the optimal one for that model and dataset. This procedure is equivalent to a simple grid-search tuning strategy implemented through manual experimentation rather than an automatic optimization algorithm.
The experiment has been focused on the 10-fold cross-validation and partition method 80:20 in three datasets, which are: SABIC, Al-Rajhi and STC. For the optimization strategy, each dataset has been modeled out using ANN and SVM to predict the stock market price.
4.3.1 ANN
For the ANN algorithm, in the 10-fold cross-validation partition for Al-Rajhi dataset, the procedures began with searching for a Decay parameter that has two possible values: (True or False). The True value was chosen as it showed a positive effect on the experiment. For the Hidden Layer parameter, the i value has been selected to enhance the performance. The best value of the learning rate parameter is 0.5, while the default value of the Momentum parameter has been used. Also, the Normalise attribute, Nominal Binary Filter and Normalise Numeric Class parameters, the default values (True) were kept improving the performance of the model. The search for the optimal parameters for ANN algorithm of Al-Rajhi dataset with 10-fold and 80:20 partition is shown in Table 2. Moreover, Figures 5-8 present the change rate of parameter values for ANN algorithm with Al-Rajhi dataset.
Table 2. Optimum parameters for ANN model of Al-Rajhi dataset
|
Parameters |
Optimal Value with 10-fold Partition |
Optimal Value with 80:20 Partition |
|
Decay |
True |
False |
|
Hidden layer |
i |
i |
|
Learning rate |
0.5 |
0.4 |
|
Momentum |
0.2 |
0.7 |
|
Normalise Attribute |
True |
True |
|
Nominal Binary Filtir |
True |
True |
|
Normalise Numeric Class |
True |
True |
Figure 5. Decay parameter values for ANN model of Al-Rajhi dataset
Figure 6. Hidden layer parameter values for ANN model of Al-Rajhi dataset
Figure 7. Momentum parameter values for ANN model of Al-Rajhi dataset
Figure 8. Learning rate parameter values for ANN model of Al-Rajhi dataset
4.3.2 SVM
Furthermore, for the SVM algorithm in 10-fold cross-validation partition of Al-Rajhi dataset, the optimization is performed through obtaining the optimum values for each parameter. The procedures for searching the optimal parameters are as follows: the SVM types parameter is being evaluated in two types. The nu-SVR (regression) type has a better performance in the experiment than epsilon-SVR (regression) type. Then, Normalize parameter is carried out with the two types of SVM to present the optimum parameter value. The True value with nu-SVR type has the best performance, as shown in Figure 9. Furthermore, the linear kernel type obtained the best performance among all other kernel types in the experiment. The performance of all kernel types is presented in Figure 10. The default values of cost (2) and eps (0.001) parameters achieved the best performance, as shown in Figures 11 and 12. Additionally, the best value for the nu parameter is 0.5 as shown in Figure 13; whereas the default value of shrinking parameter, which is True, recorded the best performance. The SVM optimal parameters of Al-Rajhi dataset for 10-fold and 80:20 partition is presented in Table 3.
Figure 9. SVM type parameter values for SVM model of Al-Rajhi dataset
Figure 10. Kernel type parameter values for SVM model of Al-Rajhi dataset
Figure 11. Cost parameter values for SVM model of Al-Rajhi dataset
Figure 12. Epsilone parameter values for SVM model of Al-Rajhi dataset
Figure 13. nu parameter values for SVM model of Al-Rajhi dataset
Table 3. Optimum parameters for SVM model of Al-Rajhi dataset
|
Parameters |
Optimal Value with 10-fold Partition |
Optimal Value with 80:20 Partition |
|
SVM type |
nu-SVR |
nu-SVR |
|
Normalize |
True |
True |
|
Kernel type |
Linear |
RBF |
|
Degree |
3 |
3 |
|
Cost |
2 |
1 |
|
Loss |
0.1 |
0.1 |
|
Eps |
0.001 |
0.001 |
|
Gama |
0 |
0 |
|
Nu |
0.5 |
0.5 |
|
Shrinking |
True |
True |
The same procedures are applied on STC and SABIC datasets with 10-fold cross-validation and 80:20 partition method for ANN and SVM algorithms which shows the optimal parameters values of the two datasets.
4.4 Ensemble through parameter optimization
From the literature review, we noticed that most of the previous studies proposed a forecasting model for a specific stock market dataset. Thus, the aim of this research revolves around the idea of creating a single model that works efficiently with any of the three companies’ datasets of the Saudi stock market that were considered in this study. In other words, instead of having three models for the three proposed datasets we will have a single model that combines and takes advantage of the three models that works for a specific dataset. In addition, the proposed ensemble model would obtain more accurate results than the single models that work for a specific dataset as it has been proved in Section 5.1. Accordingly, the voting ensemble algorithm is proposed to combine the 12 models to become a single model that works for any of the three datasets.
Figure 14. Combination rules parameter values for voting ensemble algorithm of Al-Rajhi dataset
In order to find the best combination rule for the proposed voting model, the combination rule parameter is being tested in four types which are average, median, minimum probability and maximum probability. It has been found that the median value gets the best performance measurement for the combination rule parameter, as shown in Figure 14.
This section describes and analyses the effects of applying the three techniques which are SVM, ANN and voting ensemble method with window of size five in the three datasets. The experiment was conducted by partitioning the dataset into training and testing sets using 10-fold cross-validation and 80:20 partition. The models were evaluated by using Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Relative Absolute Error (RAE), R-Squared ($R^2$) and Correlation Coefficient (R) as shown in Tables 4-6.
Table 4 shows the evaluation of the three techniques’ performance with window of size five and the optimal parameters that were presented in Table 2 and Table 3 for Al-Rajhi dataset. From the experiment results, we found that the highest performance was obtained when the holdout partition method was used. SVM, ANN, and Voting achieved approximately similar performance in terms of MAE, RMSE, RAE, R, and R2 when 80:20 partition method is applied. Moreover, we found that the SVM achieved better performance compared to ANN and Voting in terms of MAE, RMSE, RAE, R, and R2 when the 10-fold cross-validation method is used.
Table 5 shows the evaluation of the three techniques’ performance with window of size five and the optimal parameters for SABIC dataset. From the experiment results, we found that the highest performance was obtained when the holdout partition method is used. SVM achieved higher performance in terms of MAE, RMSE, RAE, R, and R2, which are 1.2584, 2.1423, 7.5300%, 0.9954 and 0.9908 respectively, when the 80:20 partition method is applied. Moreover, we found that Voting achieved a better performance compared to ANN and SVM in terms of MAE, RMSE, RAE, R, and R2, which are 1.2908, 2.1428, 8.1761%, 0.9950 and 0.9900 respectively when the 10-fold cross-validation method is used.
Table 4. Results of using window of size five for SABIC dataset
|
Quality Measures |
10-fold |
80:20 |
||||
|
SVM |
ANN |
Voting |
SVM |
ANN |
Voting |
|
|
MAE |
1.2909 |
1.3357 |
1.2908 |
1.2584 |
1.2795 |
1.2698 |
|
RMSE |
2.1502 |
2.1714 |
2.1428 |
2.1423 |
2.1574 |
2.1649 |
|
RAE |
8.1767% |
8.4608% |
8.1761% |
7.5300% |
7.6604% |
7.6026% |
|
R |
0.9949 |
0.9948 |
0.9950 |
0.9954 |
0.9954 |
0.9953 |
|
R2 |
0.98983 |
0.9896 |
0.9900 |
0.9908 |
0.9908 |
0.9906 |
Table 5. Results of using window of size five for SABIC dataset
|
Quality Measures |
10-fold |
80:20 |
||||
|
SVM |
ANN |
Voting |
SVM |
ANN |
Voting |
|
|
MAE |
1.2909 |
1.3357 |
1.2908 |
1.2584 |
1.2795 |
1.2698 |
|
RMSE |
2.1502 |
2.1714 |
2.1428 |
2.1423 |
2.1574 |
2.1649 |
|
RAE |
8.1767% |
8.4608% |
8.1761% |
7.5300% |
7.6604% |
7.6026% |
|
R |
0.9949 |
0.9948 |
0.9950 |
0.9954 |
0.9954 |
0.9953 |
|
R2 |
0.98983 |
0.9896 |
0.9900 |
0.9908 |
0.9908 |
0.9906 |
Table 6. Results of using window of size five for STC dataset
|
Quality Measures |
10-fold |
80:20 |
||||
|
SVM |
ANN |
Voting |
SVM |
ANN |
Voting |
|
|
MAE |
0.7392 |
0.7726 |
0.7490 |
0.7381 |
0.7822 |
0.7518 |
|
RMSE |
1.3352 |
1.3531 |
1.3472 |
1.2637 |
1.3140 |
1.2965 |
|
RAE |
4.3619% |
4.5590% |
4.4198% |
4.3470% |
4.6070% |
4.4279% |
|
R |
0.9981 |
0.9980 |
0.9980 |
0.9983 |
0.9982 |
0.9982 |
|
R2 |
0.9962 |
0.9960 |
0.9960 |
0.9966 |
0.9964 |
0.9964 |
Table 6 shows the evaluation of the three techniques’ performance with window of size five and the optimal parameters that were presented for STC dataset. From this experiment results, we found that the highest performance was obtained when the holdout partition method is used. SVM achieved higher performance in terms of MAE, RMSE, RAE, R, and R2, which 0.7381,1.2637, 4.3470%, 0.9983 and 0.9966 respectively, when 80:20 partition method is applied. Moreover, we found that the SVM followed by Voting achieved a better performance compared to ANN in terms of MAE, RMSE, RAE, R, and R2 when 10-fold cross-validation method is used.
Finally, many experiments have been conducted in this work in order to build a set of models for each dataset separately. This work aims to propose a high-performance model that works with any of the three Stock market datasets and forecasts the closing price based on past closing prices. To achieve the mentioned goal, voting model has been used to predict the closing price for any of the three proposed datasets. Voting method outperformed the ANN model and recorded similar performance to the SVM as well as being suitable for any of the three data sets.
5.1 Further discussion
This section demonstrates the efficiency of the proposed ensemble model through several comparisons in which the proposed ensemble model was superior to others by giving more accurate values, as shown in Figure 15. In order to prove the efficiency of this model, several comparisons have been performed between the proposed ensemble model, which fits any of the three datasets and combines the 12 models, with an ensemble model that combines 4 models that were generated for a specific company dataset. The comparison was made through the following steps:
Tables 7-9 present the performance of the proposed Ensemble (voting) model compared with the company-specific ensemble models developed for the Al-Rajhi, SABIC, and STC datasets. Across all datasets and performance measures (MAE, RMSE, and correlation coefficient R), the proposed voting ensemble consistently delivers better or at least comparable results.
Table 7. Performance measures for Al-Rajhi ensemble model vs. the proposed Ensemble (voting) model
|
Dataset |
Al-Rajhi Ensemble Model |
The Proposed Ensemble (voting) Model |
||||
|
MAE |
RMSE |
R |
MAE |
RMSE |
R |
|
|
Al-Rajhi |
0.6218 |
1.1011 |
0.9955 |
0.5763 |
1.0042 |
0.9961 |
|
SABIC |
1.2679 |
2.1729 |
0.9953 |
1.2633 |
2.1549 |
0.9954 |
|
STC |
0.7514 |
1.333 |
0.9981 |
0.7471 |
1.3163 |
0.9982 |
Table 8. Performance measures for STC ensemble model vs. the proposed Ensemble (voting) model
|
Dataset |
STC Ensemble Model |
The Proposed Ensemble (voting) Model |
||||
|
MAE |
RMSE |
R |
MAE |
RMSE |
R |
|
|
Al-Rajhi |
0.6109 |
1.1565 |
0.995 |
0.5763 |
1.0042 |
0.9961 |
|
SABIC |
1.2962 |
2.2057 |
0.9952 |
1.2633 |
2.1549 |
0.9954 |
|
STC |
0.7472 |
1.3035 |
0.9982 |
0.7471 |
1.3163 |
0.9982 |
Table 9. Performance measures for SABIC ensemble model vs. the proposed Ensemble (voting) model
|
Dataset |
SABIC Ensemble Model |
The Proposed Ensemble (voting) Model |
||||
|
MAE |
RMSE |
MAE |
RMSE |
MAE |
RMSE |
|
|
Al-Rajhi |
0.5959 |
0.966 |
0.5959 |
0.966 |
0.5959 |
0.966 |
|
SABIC |
1.3524 |
2.2706 |
1.3524 |
2.2706 |
1.3524 |
2.2706 |
|
STC |
0.7684 |
1.3529 |
0.7684 |
1.3529 |
0.7684 |
1.3529 |
A clear pattern emerges from these tables. First, the proposed model achieves the lowest MAE values for all three datasets (0.5763 for Al-Rajhi, 1.2633 for SABIC, and 0.7471 for STC), outperforming each company-specific ensemble model. Second, the RMSE values produced by the proposed model are also generally lower, indicating improved prediction stability and reduced overall error. Third, the model maintains a slightly higher correlation coefficient, reflecting better alignment between predicted and actual stock values.
These improvements suggest that the voting ensemble benefits from combining the predictive strengths of multiple models rather than relying on a single company-specific ensemble. From an ensemble-learning perspective, the voting strategy reduces variance, smooths out individual model errors, and leverages complementary information across the base learners. This helps explain why the proposed model performs consistently well across all datasets, regardless of which company’s data it was trained on originally.
Furthermore, the results indicate that the proposed model generalizes more effectively across different stock market datasets. While the company-specific models are optimized for a single dataset, their performance decreases when applied to data from other companies. In contrast, the proposed voting ensemble maintains stable and superior performance across all scenarios, demonstrating stronger robustness and adaptability.
Figure 15 visually confirms these observations. It shows that the proposed model obtains lower MAE and RMSE compared with each company’s ensemble model, reinforcing the numerical findings in Tables 7-9. This consistent pattern across datasets and evaluation metrics highlights the efficiency and superiority of the proposed approach.
Figure 15. MAE and RMSE for the proposed model and other ensemble model
Overall, the combined evidence demonstrates that the proposed voting ensemble provides more accurate, stable, and generalizable predictions than the individual company-specific ensemble models.
The need to accurately forecast stock prices is one of the most important challenges in the financial field in order to reduce the risks associated with stock market fluctuations. This work summarizes and presents the most recent works that have been published in the stock market prediction area. To the best of our knowledge, we noticed that there is a shortage of published works focusing on the Saudi stock market prediction. The main goal of this work is to forecast the next day’s closing price of the Saudi stock market using previous days' closing prices. A set of machine learning algorithms, including ANN, SVM, and voting ensemble algorithm were evaluated to get a high-performance model. The empirical study was applied to three popular companies’ datasets in Saudi Arabia, including SABIC, Al Rajhi, and STC. One of the important goals of this study is to build a singular model for the Saudi stock market that achieves a good forecasting performance with any of three companies’ datasets rather than building a specific model for each company’s dataset. Therefore, the voting ensemble model combined 12 models with the aim of proposing one suitable model for forecasting stock market prices for any of the three companies’ datasets. The experimental results indicate that the voting ensemble model obtained a better performance, with a window size of two, than other models with 1.0042, 2.1549, and 1.3163 RMSE for AlRajhi, SABIC and STC respectively.
Although the proposed model achieves good results, it also has some limitations. The ensemble method improves accuracy, but it behaves like a black-box model, which makes it difficult to explain how the predictions are generated. In future work, we plan to apply explainable AI (XAI) techniques to make the model more transparent, show the contribution of different input features, and provide clearer explanations of the predictions. Overall, this study confirms that ensemble learning is effective for stock price prediction and suggests several directions to improve the model in terms of interpretability, robustness, and use in real trading environments.
[1] Han, J.W., Kamber, M., Pei, J. (2012). Data Mining: Concepts and Techniques. Elsevier Inc. https://www.sciencedirect.com/book/monograph/9780123814791/data-mining-concepts-and-techniques.
[2] Huang, M.W., Chen, C.W., Lin, W.C., Ke, S.W., Tsai, C.F. (2017). SVM and SVM ensembles in breast cancer prediction. PLoS ONE, 12(1): e0161501. https://doi.org/10.1371/journal.pone.0161501
[3] Sachdeva, A., Jethwani, G., Manjunath, C., Balamurugan, M., Krishna, A.V.N. (2019). An effective time series analysis for equity market prediction using deep learning model. In 2019 International Conference on Data Science and Communication (IconDSC), Bangalore, India, pp. 1-5. https://doi.org/10.1109/IconDSC.2019.8817035
[4] Ramaswami, G., Susnjak, T., Mathrani, A., Lim, J., Garcia, P. (2019). Using educational data mining techniques to increase the prediction accuracy of student academic performance. Information and Learning Sciences, 120(7-8): 451-467. https://doi.org/10.1108/ILS-03-2019-0017
[5] Nielson, J., Bhaganagar, K., Meka, R., Alaeddini, A. (2020). Using atmospheric inputs for Artificial Neural Networks to improve wind turbine power prediction. Energy, 190: 116273. https://doi.org/10.1016/j.energy.2019.116273
[6] Ghani, M.U., Awais, M., Muzammul, M. (2019). Stock market prediction using machine learning(ML)algorithms. ADCAIJ: Advances in Distributed Computing and Artificial Intelligence Journal, 8(4): 97-116. https://doi.org/10.14201/ADCAIJ20198497116
[7] Behal, V., Singh, R. (2020). A comparative study on machine learning techniques for benzene prediction. In Futuristic Trends in Networks and Computing Technologies. FTNCT 2019. Communications in Computer and Information Science, pp. 565-578. https://doi.org/10.1007/978-981-15-4451-4_45
[8] Yousif, A., Elfaki, F. (2017). Artificial Neural Network versus linear models forecasting doha stock market. Journal of Physics: Conference Series, 949(1): 012014. https://doi.org/10.1088/1742-6596/949/1/012014
[9] Sirimevan, N., Mamalgaha, I.G.U.H., Jayasekara, C., Mayuran, Y.S., Jayawardena, C. (2019). Stock market prediction using machine learning techniques. In 2019 International Conference on Advancements in Computing (ICAC), Malabe, Sri Lanka, pp. 192-197. https://doi.org/10.1109/ICAC49085.2019.9103381
[10] Al-Shehri, H., Al-Qarni, A., Al-Saati, L., Batoaq, A., Badukhen, H., Alrashed, S. (2017). Student performance prediction using Support Vector Machine and K-Nearest Neighbor. In 2017 IEEE 30th Canadian Conference on Electrical and Computer Engineering (CCECE), Windsor, ON, Canada, pp. 1-4. https://doi.org/10.1109/CCECE.2017.7946847
[11] Olatunji, S.O. (2017). Extreme Learning machines and support vector machines models for email spam detection. In 2017 IEEE 30th Canadian Conference on Electrical and Computer Engineering (CCECE), Windsor, ON, Canada, pp. 1-6. https://doi.org/10.1109/CCECE.2017.7946806
[12] Polikar, R. (2012). Ensemble learning. In Ensemble Machine Learning, pp. 1-34. https://doi.org/10.1007/978-1-4419-9326-7_1
[13] AlQasrawi, L., Awad, M., Hodrob, R. (2024). A hybrid model of neural networks and genetic algorithms for prediction of the stock market price: Case study of palestine. Journal of Scientific & Industrial Research, 83(4): 432-444. https://doi.org/10.56042/jsir.v83i4.5559
[14] Alotaibi, S.S. (2021). Ensemble technique with optimal feature selection for Saudi stock market prediction: A novel hybrid red deer-grey algorithm. IEEE Access, 9: 64929-64944. https://doi.org/10.1109/ACCESS.2021.3073507
[15] Nabipour, M., Nayyeri, P., Jabani, H., Shahab, S., Mosavi, A. (2020). Predicting stock market trends using machine learning and deep learning algorithms via continuous and binary data; a comparative analysis. IEEE Access, 8: 150199-150212. https://doi.org/10.1109/ACCESS.2020.3015966
[16] Moghar, A., Hamiche, M. (2020). Stock market prediction using LSTM recurrent neural network. Procedia Computer Science, 170: 1168-1173. https://doi.org/10.1016/j.procs.2020.03.049
[17] Sarode, S., Tolani, H.G., Kak, P., Lifna, C.S. (2019). Stock price prediction using machine learning techniques. In 2019 International Conference on Intelligent Sustainable Systems (ICISS), Palladam, India, pp. 177-181. https://doi.org/10.1109/ISS1.2019.8907958
[18] Pahwa, K., Agarwal, N. (2019). Stock market analysis using supervised machine learning. In 2019 International Conference on Machine Learning, Big Data, Cloud and Parallel Computing (COMITCon), Faridabad, India, pp. 197-200. https://doi.org/10.1109/COMITCon.2019.8862225
[19] Zhong, X., Enke, D. (2019). Predicting the daily return direction of the stock market using hybrid machine learning algorithms. Financial Innovation, 5: 24. https://doi.org/10.1186/s40854-019-0138-0
[20] Al-Thelaya, K.A., El-Alfy, E.S.M., Mohammed, S. (2019). Forecasting of bahrain stock market with deep learning: Methodology and case study. In 2019 8th International Conference on Modeling Simulation and Applied Optimization (ICMSAO), Manama, Bahrain, pp. 1-5. https://doi.org/10.1109/ICMSAO.2019.8880382
[21] Ojo, S.O., Owolawi, P.A., Mphahlele, M., Adisa, J.A. (2019). Stock market behaviour prediction using stacked LSTM networks. In 2019 International Multidisciplinary Information Technology and Engineering Conference (IMITEC), Vanderbijlpark, South Africa, pp. 1-5. https://doi.org/10.1109/IMITEC45504.2019.9015840
[22] Wang, H.W., Lu, S., Zhao, J.C. (2019). Aggregating multiple types of complex data in stock market prediction: A model-independent framework. Knowledge-Based Systems, 164: 193-204. https://doi.org/10.1016/j.knosys.2018.10.035
[23] Rustam, Z., Kintandani, P. (2019). Application of support vector regression in Indonesian stock price prediction with feature selection using particle swarm optimisation. Modelling and Simulation in Engineering, 2019(1): 8962717. https://doi.org/10.1155/2019/8962717
[24] Kumar, I., Dogra, K., Utreja, C., Yadav, P. (2018). A comparative study of supervised machine learning algorithms for stock market trend prediction. In 2018 Second International Conference on Inventive Communication and Computational Technologies (ICICCT), Coimbatore, India, pp. 1003-1007. https://doi.org/10.1109/ICICCT.2018.8473214
[25] Ebadati, O.M., Mortazavi, M. (2018). An efficient hybrid machine learning method for time series stock market forecasting. Neural Network World, 28(1): 41-55. https://doi.org/10.14311/NNW.2018.28.003
[26] Usmani, M., Adil, S.H., Raza, K., Ali, S.S.A. (2016). Stock market prediction using machine learning techniques. In 2016 3rd International Conference on Computer and Information Sciences (ICCOINS), Kuala Lumpur, Malaysia, pp. 322-327. https://doi.org/10.1109/ICCOINS.2016.7783235
[27] Elgibaly, A.A., Elkamel, A.M. (1998). A new correlation for predicting hydrate formation conditions for various gas mixtures and inhibitors. Fluid Phase Equilibria, 152(1): 23-42. https://doi.org/10.1016/S0378-3812(98)00368-9
[28] Haykin, S. (2009). Neural Networks and Learning Machines. Prentice Hall.
[29] Heidari, E., Sobati, M.A., Movahedirad, S. (2016). Accurate prediction of nanofluid viscosity using a multilayer perceptron Artificial Neural Network (MLP-ANN). Chemometrics and Intelligent Laboratory Systems, 155: 73-85. https://doi.org/10.1016/j.chemolab.2016.03.031
[30] Smola, A.J., Schölkopf, B. (2004). A tutorial on support vector regression. Statistics and Computing, 14: 199-222. https://doi.org/10.1023/B:STCO.0000035301.49549.88
[31] Forghani, Y., Sigari Tabrizi, R., Sadoghi Yazdi, H., Akbarzadeh-T., M.R. (2011). Fuzzy support vector regression. In 2011 1st International Conference on Computer and Knowledge Engineering (ICCKE), Mashhad, Iran, pp. 28-33. https://doi.org/10.1109/ICCKE.2011.6413319
[32] Kittler, J., Hatef, M., Duin, R.P.W., Matas, J. (1998). On combining classifiers. IEEE Transactions on Pattern Analysis and Machine Intelligence, 20(3): 226-239. https://doi.org/10.1109/34.667881
[33] Aldukhi, F. (2020). Saudi daily stocks history (Tadawul). https://www.kaggle.com/aldukhi2/saudi-daily-stocks-history-test/version/6.
[34] The Weka Workbench. https://www.cs.waikato.ac.nz/ml/weka/.