# Analysis of the Pre and Post-COVID-19 Lockdown Use of Smartphone Apps in Spain
## 4 Methods  
The methods used in this work involve some of the most popular machine learning algorithms for unsupervised tasks. Unsupervised learning refers generally to the use of machine learning techniques to discover patterns in data that could be useful for extracting information about them and, eventually could allow the drawing of important conclusions. The most extended unsupervised algorithms are clustering methods. In contrast, supervised learning techniques are related to prediction tasks (regression or classification) where a model is built and trained to predict some particular attribute of the data called label or target. Clustering is the process of dividing the data into groups of points with similar behavior and which differ in some way from other samples that belong to other clusters. Clustering methods use all the attributes of the data to assign each point to a certain group called _cluster_ based on a concept of dissimilarity between points. This criterion used could be a distance-based dissimilarity metric. In that case, multiple distance metrics such as Euclidean, Manhattan, Mahalanobis, etc. could be used. In clustering, there is not a clear criterion to evaluate the clustering performance and the quality of the clusters formed. Consequently, it is the user who should supply this criterion, in such a way that the result of the clustering will suit their needs. In the task at hand, a good clustering criterion should be able to separate into different clusters those users that exhibit different behaviors due to their different traits. Therefore, we tried to find natural groupings in data which gathered completely different user profiles in different clusters. The clustering map was built using the K-means algorithm [42]. K-means and its variants are the most popular approach for unsupervised clustering tasks. K-means clustering minimizes within-cluster variances, i.e., a point is assigned to the cluster that minimizes  
Figure 3: Logarithmic transformation applied to normalize the WhatsApp pre-lockdown usage time variable: (**a**) original distribution; (**b**) distribution after applying the logarithmic transformation, which shows a more normally distributed behavior. the squared Euclidean distance between that point and the center of the cluster, referred to as _centroid_, which is the mean of the points assigned to that cluster. A summary of the K-means implementation is described in Algorithm 1. The main advantages of K-means are basically that convergence is guaranteed and the fact that it is simple (the user only needs to provide the number of clusters that will be formed), fast in terms of computational cost, but it is also scalable to large datasets. ```
Requires: Specify the number k of clusters to assign. Initialization: Randomly initialize k centroids. whileCentroid positions keep changingdo  1. Assign each point to its closest centroid  2. Compute the new centroid of each cluster as the mean between all the points belonging to the cluster. end
```  
**Algorithm 1**K-means algorithm  
K-means clustering was evaluated on the smartphone use data set, including as features the selected apps (Games and Phone usage are included too). In this case, we have applied the clustering only to variables related to usage times in apps, since the groups should be formed in a natural way based on these attributes without forcing a discrimination based on features such as the age. However, it is also possible to visualize the effect of those variables _a priori_ excluded from the analysis. In this particular case, the clustering was made using the usage time on the pre-lockdown period. The analysis of the clusters provides general insight about the natural groups present on the data. However, one problem that arises is interpretability, as the clustering is made in this case in an eight-dimensional space. This fact impedes the visualization of the shape and size of the clusters unless random 2D projections of that space are drawn, which in turn causes a loss of information.