# Unleashing the Power of Tweets and News in Stock-Price Prediction Using Machine-Learning Techniques
## 3 Problem Definition and Formulation
### Multiple-Layer Perceptron (MLP) Network  
A multiple-layer perceptron (MLP) is a specific feed-forward NN designed to analyze non-linear data effectively. It comprises multiple layers of perceptrons, each functioning as an algorithm for supervised learning. MLP's capacity to handle chaotic and non-linear data is enhanced by increasing the number of perceptrons. A concise representation of the input variable processing within an MLP is depicted through the following mathematical expression:  
\[Y_{n}(t)=\Phi\Bigg{(}\sum_{n}w_{n}^{o}.\Phi\Bigg{(}\sum_{k}w_{k_{n}}^{h}X_{k}(t)+b _{n}^{h}\Bigg{)}+b_{n}^{o}\Bigg{)} \tag{1}\]  
where \(X_{k}\) denotes the value of the \(k\)th variable input into the perceptron, \(w_{k}\) represents the corresponding weight, \(b\) is the bias, and \(\Phi\) is the activation function, including the _sigmoid_ and _tanh_ functions ([23; 49]). Furthermore, \(K_{n}\) denoted the number of neurons in the \(n\)th layer. These layers fall into three categories: (i) input, (ii) output, and (iii) hidden layers. Finally, \"\(\sigma\)\" represents values associated with the output neurons, and \"\(\eta\)\" represents values associated with the hidden neurons. While it has been established that a single hidden layer in a neural network can approximate any univariate function [149], stock-price prediction inherently involves multi-variate complexities. Given the successful approximation of multi-variate functions with just two hidden layers in a simple feed-forward network [150; 151], we adopt an NN configuration with two hidden layers for the MLP network.  
Although various cost functions have been explored for the MLP network in the literature, we specifically opt for the mean squared error (MSE). The effectiveness of MSE in optimizing NNs has previously been demonstrated [152], thereby showcasing its ability to handle an extensive magnitude of training data [153]. Additionally, we employ the Adam (Adaptive Moment) optimization algorithm. This algorithm was first introduced by [PERSON] et al. [154] and has been tested by researchers at OpenAI and Google Deepmind [154; 155]. Adam has been found to be successful in handling non-stationary data while also being able to handle both sparse and noisy gradients.  
The number of hidden nodes is another parameter that should be determined for NN configuration. Unlike epoch iterative testing, a generally agreed-upon formula can guide the establishment of a testing range for the optimal number of hidden nodes. This formula is presented as follows:  
\[N_{h}=\frac{N_{s}}{\alpha(N_{i}+N_{o})} \tag{2}\]  
where \(N_{h}\) denotes the number of hidden nodes, \(N_{i}\) denotes the number of input neurons, and \(N_{o}\) and \(N_{s}\) denote the number of output neurons and samples in the training dataset, respectively. Finally, \(\alpha\) is an arbitrary scaling factor, usually 2-10. With a training dataset comprising 1000 samples, an input layer of six neurons, and an output layer of one neuron, we have opted for 13 hidden neurons in the MLP. Another critical aspect of the design process involves determining the number of epochs. Since the optimal number of epochs should be established on a case-by-case basis, we have conducted iterative testing to identify the point at which the loss function ceases to decrease. It is worth noting that, despite the iterative approach, we have set a maximum limit of 5000 epochs for the MLP for the sake of simplicity.