# Exploring Pandemics Events on Twitter by Using Sentiment Analysis and Topic Modelling
## 7 Topic Modelling  
In our study we have applied the LDA model that performs the following operations several times to create documents: First, it selects one of the predefined topics with a certain probability, and then selects a word under that topic with a certain probability. Assume there are \(M\) documents with \(K\) topics. Each document (length \(N\)) has its own topic distribution that is polynomial with the parameters of the polynomial distribution that obey the Dirichlet distribution and are \(\alpha\). Each topic has its own word distribution that is a multinomial distribution with the parameters of the multinomial distribution that obey the Dirichlet distribution and are \(\beta\). For the creation of the \(n\)-th word in a given document, a topic is first selected from the topic distribution of that document, and then a word is selected from the word distribution corresponding to that topic. This generation process is repeated until all \(M\) documents complete the above process.  
We have used the gensim library [47] to perform the LDA. Apart from the input of the sentence vector (bag of words) and the dictionary (id and word), it is essential to specify the number of topics. In order to find the optimal values, topic coherence is employed as the indicator to measure the performance of the model. It is meaningful to calculate the frequency of the co-occurrence of the words belonging to the same topic in the corpus. Topic coherence does just that. The gensim library offers several different measures of topic coherence, and the main difference is the definition of \"co-occurrence\", where c_v, c_uci, u_mass, and c_npmi are optional methods. Here, the number of topics varies from 1 to 20 to find an optimal value that maximises the c_v coherence.  
Figure 12 shows that seven is the optimal value of the number of topics. The model with seven topics can obtain a relatively high coherence score.  
\begin{table}
\begin{tabular}{l c c} \hline \hline
**Cluster** & **Interpretation** & **Top Words** \\ \hline cluster0 & people’s activity such as National Women and Girls HIV/AIDS Awareness Day & people, awareness, national \\ \hline cluster1 & medical treatment & vaccine, people, mask \\ \hline cluster2 & fight against viruses & world, health, fight \\ \hline cluster3 & pandemic situation in a certain area & outbreak, Congo, city \\ \hline cluster4 & avian & bird, county, flock \\ \hline cluster5 & deaths & die, people, time \\ \hline cluster6 & war and conflict & Ukraine, Russia, kill \\ \hline cluster7 & cause of viruses & mosquito, world \\ \hline \hline \end{tabular}
\end{table}
Table 2: Interpretation of clustering on FastText.  
Figure 12: Determining optimal number of topics.  
The LDA model can be used to extract the latent topics. Its results can be visualised with the pyLDAvis library [48], which is an open-source package in Python, to interactively present the results of the LDA. Figure 13 shows the top 30 words and the main topics that can be explained as follows: Topic1--malaria; Topic2--cholera in Mariupol, Ukraine; Topic3--tuberculosis; Topic4--stop HIV/AIDS; Topic5--influence or flu; Topic6--new cases infected; and Topic7--other diseases, such as cancer. This result is too general because there are 11 different epidemics sources.