# LDA-Based Topic Modeling Sentiment Analysis Using Topic/Document/Sentence (TDS) Model
## 4 Experimental Results and Analysis
### Performance Measurement  
For the evaluation check, we used a confusion matrix that is commonly used to describe the data classification performance in three metrics: accuracy, recall, and precision, as highlighted in Equations (7)-(9), and Table 2.  
\[Accuracy=\frac{TP+TN}{TP+TN+FP+FN} \tag{7}\]  
\[Recall=\frac{TP}{TP+FN} \tag{8}\]  
\[Precision=\frac{TP}{TP+FP} \tag{9}\] \begin{table}
\begin{tabular}{c c} \hline Number of unique words in initial documents & 163,721 \\ \hline Number of unique words after removing rare & 24,960 \\ and common words & 50,000 \\ Number of unique tokens & 24,960 \\ \hline \end{tabular}
\end{table} 
Table 1: Processed data. To evaluate our model, we first divided each document into two parts and analyzed whether the topics assigned were similar. To implement this analysis process, we used a corpus LDA model transformation. The LDA transformation in every document returns topics with non-zero weights. This function then creates a matrix transformation of documents in the topic space. To compute the LDA transformation, we chose the cosine similarity method, which is a simple and effective method. For two given vectors of attributes \(A\) and \(B\), the cosine similarity is represented as:  
\[\cos\theta=\frac{A*B}{\parallel A\parallel\parallel B\parallel} \tag{10}\]  
where \(A\) represents the target sentence's word vector, and \(B\) represents the word vector of the compared sentence. \(A*B\) represent the number of shared words between word vectors \(A\) and \(B\). \(\parallel A\parallel\) and \(\parallel B\parallel\) refer to the number of words in \(A\) and \(B\). Table 3 shows an evaluation check of document similarity at the corpus level. We can say that the intra-topic similarity was highly accurate. This can be explained by the fact that topics in the corpus are perfectly modeled. Moreover, inter-topic similarity was well separated with an accuracy of 99.92%. Intra and inter document evidence has proved effective in improving sentence sentiment classification [38]. We ran the LDAvis tool for four-topic visualization to determine the most relevant terms for every topic and percentage of tokens. Moreover, this tool was also helpful for visualizing topic correlations. Table 4 highlights the most frequent terms in the case of the four topics. Frequency rate of all topics are low, which indicate the analyzed data is big or very sparse. From the frequency of words, topics can be indicated. However, as the main purpose of this study is to find those topics, sentences and words are representing which sentiment class. The TDS model implementation identified sentiment classes of data, as can be seen in Figure 4.  
Sentiment polarities are presented in Figure 4 with document level and in Figures 7 and 8 with word level. The Tokenized Word Length Distribution Table represents the polarity of documents. Length displays how the document includes sample tokenized words. As mentioned before, we have 50,000 documents and of them 24,960 are unique tokens. As can be seen from Figure 5, most of the text length is [0, 80], and the text between [0, 40] is the vast majority. The text with the length between [10, 40] is selected for the experiment as corpus sentiment analysis, and the selected experimental text length covers 14,000 texts. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Predicted** \\ \hline
**Actual** & **Positive Documents** & **Negative Documents** \\ \hline Positive documents & \# True Positive samples (TP) & \# False Negative samples (FN) \\ \hline Negative documents & \# False Positive samples (FP) & \# True Negative samples (TN) \\ \hline True positive (TP)—outcome of correctly predicted positive class, False positive (FP)—outcome of incorrectly predicted positive class, True negative (TN)—outcome of correctly predicted negative class, False negative (FN)—outcome of incorrectly predicted negative class. & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Confusion matrix. \begin{table}