# Using Social Media & Sentiment Analysis to Make Investment Decisions
## 3 Methodology and Implementation
### Design
#### 3.2.5 Deep Learning System  
The SA model was designed based on the findings in Section 2.3.2. Using those findings, the Logistic Regression Algorithm (LRA) was selected as the ideal candidate to train and evaluate the model. The LRA was chosen because it not only handles binary classification efficiently, utilizing its sigmoid function (See Figure 10), but it also can be used to output the probability of that binary value (positive or negative in this case) [6]. This probability gives a number between 0 and 1, where a positive tweet is greater than 0.5 and a negative tweet is less than 0.5. This value was important as it allowed a sentiment score to be calculated for each tweet, as required by the system (See Section 3.2.3). **Factoring SM metrics into the sentiment score:** Another finding in the literature review identified that using SM metrics is an effective way to help understand the collective sentiment of others. In our work, SM metrics are factored into the sentiment score, with the goal of trying to gauge the collective sentiment of a tweet. In this prototype, we chose to factor in the number of likes of a tweet because it shows how agreeable a tweet is with a large group of people. If a tweet has a high like count, then an assumption can be made that lots of other people feel the same way, thus identifying the collective sentiment for that tweet. To interpret this collective sentiment, a system was designed that increased the sentiment score of that tweet if it had a high like count. The aim of this feature was to make a tweet more positive or negative if lots of people agreed with it, thus more accurately mapping the collective sentiment of that tweet. To understand how this feature would work, a flowchart was created to break down the problem into simple steps (See Figure 11). Figure 10: LRA Classification Diagram [21]. As seen in the above flow chart, multiple steps are taken to factor in the like count. Firstly, the like count is normalized, which is calculated according to Equation (1):  
\[NLC=\frac{ActualLC-MinLC}{MaxLC-MinLC} \tag{1}\]  
where \(NLC\) is the normalized like count (a number between 0 and 1), \(ActualLC\) is the original like count, and \(MaxLC\) and \(MinLC\) are the minimum and maximum number of likes in the dataset of tweets. Once the like count is normalized it is then factored into the probability score according to Equation (2):  
\[Ps_{1}=Ps+(LWF\times\ NLC), \tag{2}\]  
where \(Ps_{1}\) is the updated predicted sentiment score (factoring in the like count), \(Ps\) is the original predicted sentiment score (a number between \(-0.5\) and \(0.5\)), \(NLC\) is the normalized like count and \(LWF\) is a like weighting factor. \(LWF\) is used to limit how much sentiment can be added onto \(Ps\) to ensure the updated sentiment score stays within the maximum and minimum thresholds. It is calculated according to Equation (3):  
\[LWF=MaxLWF-|Ps-MaxLWF| \tag{3}\]  
where \(MaxLWF\) sets the value limits of the \(LWF\), \(0.25\) and \(-0.25\). Note that equations 2 and 3 only factor in positive sentiment scores (a number between 0 and 0.5), hence there is also opposite equivalents for each equation used to handle negative sentiment scores (a number between \(-0.5\) and \(0\)). It's also important to note that the sentiment score is originally in the range of 0 to 1. For these equations it is converted to lie within a range of \(-0.5\) and \(0.5\), and then converted back after. The output of Equation (3) is illustrated in Figure 12. This diagram depicts the value of \(LWF\), based on the value of Ps. From it, the following conclusions can be made:  
The trend of the line shows that tweets with an already very positive or negative score, or tweets with a very low positive or negative score (aka neutral sentiment), will have a much lower LWF. Therefore, if these tweets have a high like count, less sentiment will be added to them (based on Equation (2)).