# Analysing Social Media Discourse on Electric Vehicles with Machine Learning
## 3 Materials and Methods
### Topic Modelling  
In the fields of natural language processing (NLP) and text mining, extracting meaningful structures from large text collections is an important research topic [57]. Topic modelling is a powerful technique for identifying latent topics in ambiguous or unstructured text datasets [58]. It is especially used in large text datasets to understand how certain topics are grouped and which words are associated with which topics. This method can be applied to many different types of texts, from news articles to academic papers, and social media posts to customer reviews [59].  
Topic modelling is performed by unsupervised learning methods and analyses texts without predefined tags. In this process, it determines which topics documents can belong to based on word distributions in the text [60]. One of the most widely used topic modelling algorithms is the Latent Dirichlet Allocation (LDA) model [61].  
LDA is a probabilistic model developed by [PERSON], [PERSON], and [PERSON] in 2003 and can be used to extract latent topic distributions in texts. LDA assumes that each document can contain multiple topics in certain proportions and that each topic consists of certain words [61].  
The LDA (Latent Dirichlet Allocation) model is based on two main assumptions. First, documents are assumed to be composed of topics in certain proportions, i.e., each document contains words belonging to more than one topic, and each topic can have different weights in the document [62]. Second, topics are assumed to be composed of specific words. Each topic is represented by the occurrence of certain words with a certain probability, and these words form a structure that carries a meaning specific to the topic. In this way, the LDA model aims to discover hidden structures in documents and understand the relationship between topics [63].  
The basic components of the LDA model are as follows:  
* Number of topics (K): This specifies the number of topics that the model will predict.
* Document topics (\(\theta_{\text{d}}\)): Each document is represented as a mixture of K topics. Here, \(\theta_{\text{d}}\) is the topic distribution of the \(d\)-th document.
* Topic word distributions (\(\phi_{\text{k}}\)): Each topic represents a distribution of words. That is, \(\phi_{\text{k}}\) is the word distribution of the kth topic.
* Word vector (\(w_{\text{d},n}\)): The words that make up each document. Each word is generated by a topic.  
We can express the mathematical structure of the LDA model as follows:  
\[p(w,z\,\text{Ia},\beta)=\prod_{d=1}^{D}\left(\prod_{n=1}^{N_{d}}p\big{(}(w_{ d,n}|z_{d,n},\beta)p(z_{d,n}|\theta_{d})\big{)}\right)p(\theta_{d}|\alpha)p(\beta|\eta) \tag{5}\]  
where  
* \(w_{\text{d},n}\) is the nth word in the \(d\)-th document, and \(z_{\text{d}}\), n is the predicted topic label for this word.
* \(\theta_{\text{d}}\) represents the topic distribution of the \(d\)-th document.
* \(\beta\) and \(\alpha\) are the hyperparameters of the Dirichlet distributions.  
The number of topics for LDA was determined using the coherence score metric. Multiple iterations were run with topic numbers ranging from 2 to 10, and the model with three topics yielded the highest coherence score while maintaining semantic interpretability. This approach ensured both statistical validity and practical interpretability of the topic groupings.