pISSN: 2723 - 6609 e-ISSN: 2745-5254
Vol. 5, No. 5 Mei 2024 http://jist.publikasiindonesia.id/
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2098
Predictive Analysis of Indonesian Stock Market Prices Using
Deep Learning: An Application of Diffusion Variational
Autoencoders
Ardisurya
Universitas Indonesia Depok, Indonesia
*Correspondence
ABSTRACT
Keywords: Diffusion
Variation Autoencoder;
Stock price prediction;
Indonesia stock market;
Deep Learning; Technical
Analysis.
This study introduces the application of the Diffusion
Variational Autoencoder (D-VAE), a deep learning
technique, for predicting stock prices in the Indonesian stock
market. With the challenges presented by market volatility
and complex data distributions, D-VAE is explored for its
capability to encapsulate uncertainty and model complex
distributions. This study is significant as it explores the
potential of D-VAE in the context of the Indonesian stock
market, which has not been widely studied before. Historical
stock data from Yahoo Finance was collected over one year
and preprocessed for training and validation of the model.
The model is trained with an architecture designed to allow
tuning of the latent space, utilising ReLU and linear
activation functions for the encoder and decoder. The
model's performance is evaluated using the Mean Squared
Error (MSE), Mean Absolute Error (MAE), and R-squared
metrics, yielding results that highlight the model's capability
to enhance the accuracy of stock price predictions. By
leveraging machine learning techniques in stock price
prediction models, this study underscores the significant
contribution such approaches can make to informed and
successful investment decisions underpinned by robust data.
Introduction
Stocks are financial instruments that offer investors a fraction of a company's
ownership. Investors who invest in a stock have a high percentage of the profits earned
by the company (Patel, Kumar, & Yadav, 2023). As a vital component in the economy,
the stock market is an indicator of economic health and a platform for companies to
accumulate capital. However, the high volatility of the stock market, influenced by
various factors such as the economy, politics, and social issues, makes stock price
prediction very complex and challenging (Farild, Sawaji, & Poddala, 2023).
The stock market not only acts as an indicator of economic health but also as an
arena for investors to optimise their investment decisions (Al-Alawi & Alaali, 2023).
Accuracy in stock price prediction significantly impacts companies' investment decisions.
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2099
An interesting approach in this regard is the application of the Diffusion Variational
Autoencoder (D-VAE). This deep learning technique can capture uncertainty and model
complex data distributions (Koa, Ma, Ng, & Chua, 2023). Although D-VAE has shown
potential in other domains as an application, its use for stock price prediction in the
Indonesian market has yet to be extensively explored.
Research related to stock price prediction has been growing and pushing
computational intelligence to encourage the enhancement of prediction model
performance further (Shen & Shafiq, 2020). Technical analysis, which predicts stock
prices based on historical data such as stock trading volume and price movements, and
approaches such as ARIMA (Islam & Nguyen, 2020) and Stochastic Oscillator
(Alviyanil’Izzah et al., 2021), will be utilised in this research using historical stock data
from companies in Indonesia.
On the other hand, the popularity of machine learning in predicting stock prices is
increasing, presenting systems to learn from historical data. Techniques like LSTM (Qiu,
Wang, & Zhou, 2020) and Support Vector Machine (SVM) (Madhusudan, 2020) have
been widely used in stock price prediction. This research aims to bridge a gap in the
literature by critically evaluating and applying D-VAE for stock price prediction in the
Indonesian market, offering new insights into the potential of D-VAE in this context(Nath
& Shakhari, n.d.).
Integrating machine learning, especially D-VAE, and technical analysis is expected
to yield more accurate and effective stock price prediction models for the Indonesian
stock market, making a valuable contribution to data-based investment decision-making.
Research Methods
This study was designed to test a stock price prediction model for the Indonesian
stock market using the Diffusion Variational Autoencoder (D-VAE). This approach
combines Deep Learning techniques with technical analysis to understand and predict the
dynamics of stock prices in the Indonesian stock market.
Data Collection and Preparation
The data used in this study is from Yahoo Financethe period they have taken
ranges from January 1st, 2022, to January 1st, 2023. The data consists of the columns for
the opening (Open), highest (High), lowest (Low), closing (Close) prices, and the trading
volume (Volume) of stocks in the Indonesian stock market. The collected data was then
processed to eliminate any missing data. We extracted relevant features from this data to
construct the model and the target for predictions. These features include the opening,
highest, lowest prices, and trading volume. Then, for the closing price, it becomes the
prediction target. Before feeding the data into the mel, we normalised the feature andarget
using MiMaxScaer. T steps cruciao nsmore stable d ffii earng the matheatical mode us t
normalie hedta:X
Scaled
=
X- X
min
X
max
-X
min
y
Scal
=
y- y
min
y
max
-y
min
Ardisurya
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2100
Where the value X represents the actual value of the feature to be normalised. For
Xmin, it is the minimum value of each feature in the data, serving as the lower reference
value for normalisation. Similarly, Xmax is the maximum value of each feature in the
data, serving as the upper reference value for normalisation. The value Xscaled is the
normalised value of the feature. The normalisation process changes the actual data to a
scale from 0 to 1.
While y represents the actual value of the target to be normalised, for men, it is the
smallest value among all the target values in the data. This value serves as the lower
reference point for the range of normalisation. For max, it is the most significant value
among all the target values in the data. This value serves as the upper reference point for
the range of normalisation. Finally, scale is the normalised target value. The result of this
normalisation process changes the original data into a scale from 0 to 1.
Diffusion Variational Autoencoder (D-VAE) Model Architecture
The developed D-VAE model is based on a tunable latent space architecture that
consists of an encoder and a decoder. The encoder captures the complex relationships
among the numerous features of the volatile stock market and outputs a prediction of the
closing price. The encoder operates as a data compression mechanism, encoding the input
data into a more compact representation within the latent space. This compression to a
more succinct representation is accomplished through a series of hidden layers. The input
layer receives the input, matching the number of features used. This serves as the entry
point into the D-VAE model. As for the hidden layers, they consist of multiple layers with
neuron units varying in number. These layers have the Rectified Linear Unit (ReLU)
activation function. ReLU is chosen because it does not activate at negative input values,
which can help mitigate the vanishing gradient problem, as the derivative of the ReLU
function remains constant for all positive inputs, thus facilitating a more efficient training
process.
f
󰇛
x
󰇜
=max(0,x)
In the ReLU activation function used in the D-VAE architecture, the variable x
represents the input for the ReLU function. The previous layer's output within the neural
network is used as the input for the ReLU function. If the output (f(x)) is higher than zero,
it will equal the input value; if less, it will be zero. This ensures that the output will always
be non-negative. If x is positive, f(x) will be equal to x, but if x is negative, f(x) will be
zero. This helps address the vanishing gradient problem because the derivative of the
ReLU function is consistent for all positive values, thus ensuring efficient
backpropagation during training.
The decoder layer operates as a mechanism to extract the compressed representation
from the encoder and reconstruct the original expected output. This is the inverse process
of the encoder. The decoder architecture mirrors that of the encoder but in reverse order.
The main difference in its implementation is that it aims to gradually expand the succinct
representation from the encoder back to its original form that is more detailed and specific
to the prediction target.
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2101
f(x) = x
The output layer consists of a single neuron with a linear activation function. This
function maintains the input value without any changes, allowing the model to predict
continuous values. In the context of stock price prediction, the model can produce a
prediction value that is sufficiently accurate for the stock's closing price.
Training and Evaluation of the Model
The Diffusion Variational Autoencoder (D-VAE) model is trained using normalised
data to ensure all features are on the same scale. This approach can improve the model's
ability to capture patterns and trends present in the data more effectively.
We employed the Adaptive Moment Estimation (Adam) algorithm to optimise.
Adam is an optimisation algoriththat calculates the learning rates from the scond moment
of grient using RMSPro. It computes adptive earning ratesfor eac parameter by cnsidering
the firt an second estimates of the the graie..
󰆚
θ
t+1
= θ
t
+
η
v
t
m
t
The value θ represents the model parameters or the weights of the model. These are
the values we aim to ooptimise Then, η represents the learning rate. When changing the
model parameters, this scalar value adjusts the step size during each iteration. The te m
t
represents the first estimate of the gradient. It is the average of the gradient of the loss
function concerning the model parameters. This helps to adjust the learning rate
adaptively for each parameter. Then, the te v
t
represents the second estimate of the
gradient or the uncentered variance of the gradient. The average of the squared gradient
provides an estimate of the gradient variability ofthe lvaluesunctilarto m
t
he value v
t
ed
to adjust the learning rate for each parameter while considering the scale of the gradient.
Finally, the value is a small constant added to prevent didivisiony zro when dividing b
thesquare root ftthe thehe
v
t
.. e employ Mean Squared Error (MSE), Mean Absolute
Error (MAE), and R-squared to evaluate the model used.
(y
i
-y
i
)
󰆚
n
i=1
MSE is calculated as the average of the squares of the differences between actual
and predicted values. It measures how close the predictions are to the actual values. The
value yi represents the stock's actual value being predicted. Then, y_i represents the
predicted value. Moreover, 'n' is the number of samples in tis experiment
1
n
|y
i
-y
i
|
n
i=1
MAE measures the average absolute error between predictions and actual values.
Unlike MSE, MAE provides a more linear perspective on prediction errors. The value yi
represents the stock's actual value being predicted. Then, y_i represents the predicted
value. Moreover, 'n' is the number of samples in this experiment.