# Investigating the Key Aspects of a Smart City through Topic Modeling and Thematic Analysis
## 2 Materials and Methods
### Topic Modeling
For our study, we opted for the 'all-MiniLM-L6-v2' pre-trained sentence transformer model included in SBERT. This model, trained for English language semantic similarity tasks, is well-suited for a wide range of use cases [43]. 2. Reduces the dimensionality of document embeddings. Due to the \"curse of dimensionality\", clustering algorithms struggle to efficiently handle high-dimensional data. Since SBERT maps sentences to a 384-dimensional dense vector space, there arises a requirement for reducing the dimensionality of these representations. For our use case, we selected the uniform manifold approximation and projection (UMAP) [49], a practical and scalable algorithm suitable for dimensionality reduction in real-world data. UMAP is a technique capable of retaining aspects of a dataset's local and global structure while reducing its dimensionality. 3. Creates clusters of semantically similar documents, each representing a distinct topic. Following the reduction in embeddings, the subsequent step involves generating clusters of documents that share semantic similarity. BERTopic incorporates a variation in widely used clustering algorithms, such as K-means or agglomerative clustering. However, as these techniques are susceptible to noise, we employed the hierarchical density-based spatial clustering of applications with noise (HDBSCAN) [50]. HDBSCAN is adept at identifying clusters of various shapes and has the valuable capability of detecting potential outliers. Consequently, we avoid the imposition of documents into clusters where they may not indeed belong [43]. 4. Tokenizes each cluster, generating a bag-of-words representation. The selection of HDBSCAN as the chosen clustering algorithm acknowledges the potential for clusters to manifest diverse degrees of density and shapes. In essence, we seek a topic representation methodology that abstains from presupposing any a priori assumptions concerning the inherent structural compositions of clusters. To this end, we consolidated all documents within a cluster into a single, albeit lengthy, document. This composite document functions as the embodiment of the entire cluster. Importantly, this bag-of-words representation operates on the cluster level, distinct from the document level. This distinction is crucial because our interest lies in the words at the topic level or, more precisely, the cluster level. 5. Weights tokens using a class-based variant of TF-IDF to extract the topic representation from each cluster. The employment of the class-based term frequency-inverse document frequency (c-TF-IDF) serves as a metric for gauging the significance of each word concerning specific topics and for identifying the most representative word associated with each topic. The outcome offers an estimation of word importance within a given  
Figure 4: The five steps of BERTopic. cluster. This technique seamlessly lends itself to the generation of matrices for document-topic distribution and topic-word distribution, thereby proving conducive to the matrix generation process [44].