{'fraction_non_alphanumeric': 0.031015239321742865, 'fraction_numerical': 0.009524576089289548, 'mean_word_length': 4.688797313797314, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unsupervised learning for local structure detection in colloidal systems

We introduce a simple, fast, and easy to implement unsupervised learning algorithm for detecting different local environments on a single-particle level in colloidal systems. In this algorithm, we use a vector of standard bond-orientational order parameters to describe the local environment of each particle. We then use a neural-network-based autoencoder combined with Gaussian mixture models in order to autonomously group together similar environments. We test the performance of the method on snapshots of a wide variety of colloidal systems obtained via computer simulations, ranging from simple isotropically interacting systems, to binary mixtures, and even anisotropic hard cubes. Additionally, we look at a variety of common self-assembled situations such as fluid-crystal and crystal-crystal coexistences, grain boundaries, and nucleation. In all cases, we are able to identify the relevant local environments to a similar precision as "standard", manually-tuned and system-specific, order parameters. In addition to classifying such environments, we also use the trained autoencoder in order to determine the most relevant bond orientational order parameters in the systems analyzed.


I. INTRODUCTION
An important challenge in the study of colloidal selfassembly is the detection of self-assembled products in the system. When the basic phases that the system forms are well characterized, we can design order parameters that detect, on a single particle level, which of the expected phases a particle is in. This strategy has been extensively used in studies ranging from crystal nucleation and growth  , to crystal melting, and even grain boundary dynamics 5,6 . Over the years, a number of different routes have been taken to characterise such local order, including e.g. order parameters based on bond-orientational order 7-10 , common neighbor analysis (CNA) 11,12 , and templating 13 . Moreover, developments in the last few years have started to combine these local descriptions with supervised machine learning techniques in order to recognize specific crystal structures [14][15][16] . These strategies, however, only work for systems where we know a priori which phases we expect to find.
In many cases, when exploring the self-assembly of new systems, the exact final structure and its characteristics are unknown, complicating the selection of an ideal order parameter. In this context, unsupervised machine learning techniques, which excel in autonomously finding patterns in large data sets, offer a promising route for detecting self-assembled structures. In a recent paper 17 , Reinhart et al. made an attempt to use unsupervised machine learning in order to identify different crystal structures. In their work, they described the local environment of the particles with the adjacency criterion from adaptive CNA and combined it with the diffusion map technique for dimensionality reduction in order to distinguish different, frequently occurring, structures. Although very successful, this method turned out to be very computationally demanding. In a subsequent article 18 , a faster way of comparing local neighborhoods was introduced, based on a) Electronic mail: e.boattini@uu.nl. their relative graphlet frequencies. This reduced the computational cost of the algorithm by four orders of magnitude.
A different approach was followed by Spellings and Glotzer in Ref. 19, where they used a combination of unsupervised and supervised learning techniques in order to identify the overall crystal structures of bulk self-assembled systems (i.e. systems of which the majority had self-assembled into the same phase).
In this work, we present a new avenue to detect selfassembly products, and introduce an unsupervised machine learning algorithm based on bond-orientational order parameters combined with neural-network-based autoencoders [20][21][22][23][24] and Gaussian mixture models [25][26][27] . Autoencoders are a standard technique for nonlinear dimensionality reduction, while mixture models are probabilistic models for identifying distinct clusters within a data set. Using these methods, our algorithm can autonomously classify particles in different groups based on their local order, making it easy to detect any selfassembly product in the system.
In contrast to Ref. 19, the goal here is to identify local environments on a single-particle level -meaning that this method can be used to study processes like nucleation, grain boundary characteristics, and coexistences. This algorithm has been designed to be computationally fast, easily scalable to very large data sets, and extremely easy to implement. To test its performance, we examine a number of different colloidal systems, ranging from spheres, to binary mixtures, to anisotropic particles. Moreover, in addition to simply classifying local environments, we also explore whether the unsupervised learning techniques employed can help us identify the distinguishing features of the different particle environments found in the system.

II. METHODS
In this section, we describe in detail the algorithm we use to classify local environments. We start by summarizing the main steps of our approach, and then follow with a detailed description of each step in separate subsections.
The overall process consists of three steps. First, we require a method to capture the local environment of each particle in a set of local order parameters. For this, we make use of bondorientational order parameters. This set of order parameters is in general high-dimensional, and may contain significant amounts of redundant and irrelevant information. In order to extract the most relevant information, the second step of our approach makes use of a dimensionality reduction technique, namely a neural-network-based autoencoder. Once trained, the autoencoder projects the original (high-dimensional) input vectors onto a lower-dimensional subspace encoding the features with the largest variations in the input data. Ideally, in this subspace, particles with similar local environments are grouped together. Finally, we apply a clustering algorithm (Gaussian mixture models) in order to identify the distinct clusters of local environments in this lower-dimensional subspace.

A. Bond order parameters
To characterize the local environment of each particle, we use the averaged bond order parameters (BOPs) introduced by Lechner and Dellago 7,10 . First, we define for any given particle i the complex quantities where Y m l (r ij ) are the spherical harmonics of order l, with m an integer that runs from m = −l to m = +l. Additionally, r i j is the vector from particle i to particle j, and N b (i) is the set of nearest neighbors of particle i, which we will define later. Note that N b (i) contains N b (i) particles. Then, we can define an averageq lm (i) as where the sum runs over all nearest neighbors of particle i as well as particle i itself. Averaging over the nearest neighbor values of q lm results effectively in also taking next-nearest neighbors into account. Finally, we define rotationally invariant BOPs asq which, depending on the choice of l, are sensitive to different crystal symmetries. The optimal set of BOPs to be considered strongly depends on the structures one wishes to distinguish. Since our method is meant to be applied to systems for which such prior knowledge is missing, in order to describe the local environment of one particle, we evaluate severalq l with l ranging from 1 to 8. Note that in principle, one could consider a larger (or smaller) range of l. For all cases examined in this paper, however, we found 8 to be sufficient. Therefore, when considering one component systems, our description of the local environment of particle i is encoded into an 8-dimensional vector with l ∈ [1,8]. When considering binary mixtures, i.e. systems with two species of particles, the same BOPs are evaluated both considering all the nearest neighbors of the reference particle (regardless of particles' species), and considering only the nearest neighbors of the same species as the reference particle. Hence, for binary mixtures, our description of the local environment of particle i is encoded into a 16-dimensional vector where s indicates the particles' species. Here, {q l } represent the set of BOPs evaluated considering all the nearest neighbors of particle i, while the set {q ss l } is evaluated considering only the nearest neighbors of the same species s as particle i.
Thus far, we have not discussed the definition of a nearest neighbor, as used in the definition of the BOPs. There are a number of different avenues for identifying nearest neighbors. The simplest method relies on using a fixed cutoff radius r c , such that all particles closer than this distance are considered nearest neighbors. Ideally, this cutoff radius is chosen as the distance at which the radial distribution function has its first minimum. This method has the advantage that it is computationally very cheap and it is symmetric, i.e. i is a neighbor of j if and only if j is a neighbor of i. However, r c is system and density dependent, so that it has to be tuned for every particular case requiring prior knowledge of the system under study. Additionally, the cutoff is defined for the entire system and, as such, is not an optimal choice for systems with large density gradients or interfaces, such as can occur in nucleation studies.
Another standard method for determining nearest neighbors is the Voronoi construction 28 , which has the advantage that it is parameter free. However, it is also relatively computationally expensive, and in this work we have instead opted to make use of a recently introduced alternative parameter-free nearest-neighbor criterion, called SANN (solid angle nearest neighbor) 29 . In this approach, an effective individual cutoff is found for every particle in the system based on its local environment. This method is not inherently symmetric, i.e. j might be a neighbor of i while i is not a neighbor of j. However, symmetry can be enforced by either adding j to the neighbors of i or removing i from the neighbors of j. In this study, we applied the latter solution. The computational cost of SANN only slightly exceeds that of a cutoff distance, and, since it is a parameter-free method, it is suitable for systems with inhomogeneous densities. In order to extract the relevant information contained in the vectors Q(i), we use neural-network-based autoencoders [20][21][22][23][24] . An autoencoder is a neural network that is trained to perform the identity mapping, where the network inputs are reproduced at the output layer. The network may be viewed as consisting of two parts: an encoder network, which performs a nonlinear projection of the input data into a low-dimensional subspace, and a decoder network that attempts to reconstruct the input data from the low dimensional projection. This architecture is represented in Fig. 1.
By training the autoencoder to perform the input reconstruction task over an ensemble of training examples, the encoder is forced to learn a low-dimensional nonlinear projection that preserves the most relevant features of the data and from which the higher-dimensional inputs can be approximately reconstructed by the decoder. In this work, the training data are the vectors Q(i) (Eqs. 4 or 5) evaluated from snapshots of colloidal systems obtained via computer simulations, and the autoencoder is trained to find a low-dimensional projection of such vectors by eliminating irrelevant and redundant information.
In the present context, we employ feedforward and fullyconnected autoencoders like the one presented in Fig. 1. The number of input and output nodes, d, is specified by the dimensionality of the input vectors, Q(i) ∈ R d , which are approximately reconstructed by the network in the output layer, Q(i) ∈ R d . The bottleneck layer contains the low-dimensional projection to be learned by the encoder, Y(i) ∈ R c , whose dimensionality is controlled by the number of bottleneck nodes, c < d. Nonlinearity is achieved by providing both the encoder and the decoder with a fully-connected hidden layer with a nonlinear activation function. Here, we set the number of nodes in the hidden layers to 10d and use a hyperbolic tangent as the activation function. For the bottleneck and output layers, instead, a linear activation function is used.
The internal parameters of the autoencoder, i.e. weights W ≡ {w j } and biases B ≡ {b k }, are optimized during the training by minimizing the reconstruction error of the input data over a training set of N training examples. Specifically, we consider the mean squared error (MSE) with the addition of a weight decay regularization term 24 to control the magnitude of the network weights where M is the total number of weights, whose value depends on the dimension of the network, and we set λ = 10 −5 . The function in Eq. 6 is minimized using mini-batch stochastic gradient descent with momentum 24,30,31 . The optimal number of nodes in the bottleneck layer, c, which defines the unknown relevant dimensionality of the input data, can be determined by computing the reconstruction MSE and looking for the existence of an elbow in the MSE as a function of c 32 . For convenience, we rescale the MSE by the mean squared deviation (MSD) of the vectors Q(i), whereQ is the mean input vector. To detect the presence of an elbow we use the L-method proposed by Salvador and Chan 33 . For all systems examined in this work, we found a dimensionality of c = 2 to be sufficient. Once the autoencoder is trained, the encoder network alone is retained in order to perform the nonlinear mapping of the input vectors Q(i) onto the low-dimensional subspace defined by the bottleneck layer, Y(i).

Learning from the autoencoder
One of the main advantages of using a neural-networkbased autoencoder over other nonlinear techniques for dimensionality reduction is that it furnishes an exact analytical mapping (and an approximate inverse mapping) between the original input space and its low-dimensional projection. In finding such a mapping, the autoencoder must understand which of all the BOPs given as input in the vectors Q(i) are the most relevant for the system under analysis. Extrapolating this knowledge would help us understand the relevant symmetries distinguishing the different environments possibly present in the system. Several methods to assess the relative importance of input variables in neural network models have been proposed [34][35][36][37] . Here, we consider the input perturbation [34][35][36][37] and the improved stepwise 36,37 methods. Both techniques require the use of a single trained model, avoiding having to repeat the training of the autoencoder multiple times.
The input perturbation method assesses the variation in the MSE of the autoencoder by adding, in turn, a small amount of white noise to the k-th input, while holding all the other inputs at their observed values. Here, we set the white noise to 10% and 50% of each input, as suggested in Ref. 36. The input variables whose changes affect the output the most, leading to a large increase in the MSE, are the ones that have the most relative influence.
The improved stepwise method is very similar in spirit, but instead of adding noise to one of the inputs, it replaces all its values with its mean over the whole dataset. Also in this case, the most relevant input variables are identified as the ones whose replacement causes the largest increase in the MSE.
In both cases, a quantitative measure of the relative importance, RI k , of the k-th input can be obtained as where ∆E k is the variation in the MSE caused by the change applied to the k-th input, and the sum in the denominator runs over all the input variables.

Clustering
In order to cluster together similar environments in the lowdimensional subspace found by the encoder, we use Gaussian mixture models (GMMs) as implemented in scikit-learn 38 .
GMM is a probabilistic model that assumes that the observed data are generated from a mixture of a finite number of Gaussian distributions with unknown parameters. Such parameters are optimized iteratively with the expectationmaximization (EM) algorithm 25 in order to create a probability density function that agrees well with the distribution of the data. The number of Gaussian components in the mixture, N G , is usually found by minimizing the Bayesian information criterion (BIC) 26 , which measures how well a GMM fits the observed data while penalizing models with many parameters to prevent overfitting. The output of a trained GMM is a list of probabilities, p i j , corresponding to the posterior probabilities of the i-th observation to arise from the j-th component in the mixture model.
The simplest form of clustering that can be applied consists in considering each mixture component as generating a separate cluster and assigning each observation to the component with the highest posterior probability. However, while this procedure works perfectly for clusters that are really generated from a mixture of separate multivariate normal distributions, the clusters that underline our data are very often far from being Gaussian-distributed in space. As a consequence, a single cluster in the data may be detected as two or more mixture components (if its distribution is indeed better approximated by a mixture of Gaussians than by a single Gaussian function), meaning that the number of clusters in the data may in general be different from the number of components found by minimizing the BIC.
To overcome this problem, we use the method proposed by Baudry et al. 27 . The idea is to first use the BIC in order to find a GMM with N G components that fits the data well. Then, a sequence of candidate clusterings with K = N G , N G − 1, . . . , 1 clusters is formed by successively merging a pair of components. At each step, the two mixture components to be merged are chosen so as to minimize the entropy of the resulting clustering, defined as where N is the number of observations and K the number of clusters. Finally, the optimal number of clusters is found by looking for the existence of an elbow in the entropy S K as a function of K. Again, we detect the elbow with the L-method of Salvador and Chan 33 . This procedure autonomously finds the number of clusters underlying the data, corresponding to the distinct particle environments present in the system under analysis. Moreover, note that this is a soft clustering technique, meaning that each particle is not simply assigned to a cluster corresponding to a specific local environment, but rather it has a certain probability of belonging to any of the identified clusters. As a result, particles whose environment is not well defined, such as can occur at interfaces, will have similar probabilities of belonging to different clusters. In the following, we will refer to these probabilities as membership probabilities.

III. RESULTS AND DISCUSSION
In this section, we show how our method performs on snapshots of a wide range of colloidal systems obtained via computer simulations. We first present in detail the whole procedure for the analysis of a "test" example for which we compare the results with a more standard, system-specific, methodology. A shorter, more concise, discussion is dedicated to the results obtained for the other systems analyzed, including systems with grain boundaries, anisotropic hard cubes, and binary mixtures.

A. Single-component hard spheres
As a first test case we examine a snapshot from a Monte Carlo (MC) simulation of single-component hard spheres of diameter σ , which is shown in Fig. 2a. The simulation was performed in the canonical ensemble (constant number of particles N, volume V and temperature T ) and exhibited a coexistence between the fluid, hexagonal close-packed (HCP) and face-centered cubic (FCC) phases. The system contained N = 1536 particles and was at a number density ρσ 3 = 1.01.

Analysis
Starting from the raw coordinates of each particle i in the system, we build the vectors Q(i) in Eq. 4 and use them as an input for the autoencoder. To find the optimal dimensionality of the bottleneck layer, c, we evaluate the reconstruction MSE of the autoencoder for c ∈ [1,8]. A plot of the rescaled MSE as a function of c is shown in Fig. 2b. Solid lines, obtained with the L-method, clearly show the presence of an elbow at c = 2, indicating that a two-dimensional projection of the original (a) Snapshot under analysis.   input vectors is sufficient to preserve the relevant information. The projection learned by the encoder is depicted in Fig. 2e, where each point corresponds to a particle in the system. Note that the colors in Fig. 2e do not matter yet. We then apply GMM in this two-dimensional space in order to identify the relevant clusters, i.e. the distinct particle environments. Following the method of Baudry et al., we first optimize the number of Gaussian components in the mixture model, N G , by minimizing the BIC. The BIC as a function of N G is shown in Fig. 2c and has a minimum for N G = 4. Then, the optimal number of clusters, K, is found by successively merging a pair of components and looking for the existence of an elbow in the clustering entropy as a function of K (see Fig. 2d). The elbow is detected at K = 3, meaning that the unsupervised learning identifies three relevant environments. Note that we know beforehand the three phases present in the system (FCC, HCP and fluid), so that we can easily associate each cluster with the correct phase. An idea of the partitioning of space performed by the clustering is given in Fig. 2e, where the color of each point is determined by the cluster with the highest membership probability. As discussed in section II B 3, however, some points might have a non-vanishing probability of belonging to more than one cluster. In order to fully account for such additional information, in the snapshot in Fig. 2f the RGB color of the particles is obtained as a linear combination of the colors of the three clusters, with the associated membership probabilities as coefficients. As a result, particles with an environment falling at the boundary between two clusters, hence having two non-vanishing membership probabilities of similar magnitude, appear with a different color from those in the legend. This behavior is clearly observed for some of the particles at the crystal-fluid interfaces.
In the following, we compare the results obtained with a more standard methodology specifically tuned for distinguishing the phases in this system.

Comparison
A common method to classify different phases on a singleparticle basis consists in finding one (or more) pair(s) of BOPs, (q l ,q l ), whose distributions in the phases of interest are considerably different, so that it is possible to define separate regions in theq l -q l -plane corresponding to different particle environments. The pair of BOPs to consider strongly depends on the environments one wishes to distinguish, and it is usually found by trial and error.
For the FCC, HCP and fluid phases,q 4 andq 6 are the most common choice 10 . Fig. 3 shows the probability distribution ofq 4 (3a) andq 6 (3b) for the three hard-sphere phases, obtained from separate MC simulations in the canonical ensemble. Simulations of the two crystal phases were performed at a number density just above the coexistence region, ρσ 3 = 1.05, while for the fluid phase we used a number density of ρσ 3 = 0.86.
The distributions ofq 4 in the two crystals are well separated, while theq 4 distribution of the fluid phase strongly crystal phases, but a small overlap between the two crystals. Alone, none of the BOPs considered completely separates the three phases. However, a separation can be found in theq 4q 6 -plane. A comparison of the phases in theq 4 -q 6 -plane is shown in Fig. 4. In this plane, one can easily identify three linearly-separated regions associated with the three phases. A possible choice of such a separation is represented by the solid lines in Fig. 4. Based on this definition, the particles in Fig. 2a can be classified according to the region in which their BOPs fall. The results of this classification are presented in Fig. 5 and they are in excellent agreement with the ones obtained via unsupervised learning (see Fig. 2f for comparison). As can be seen by comparing Figs 2f and 5, the only differences between the two classifications are at the interfaces, and are generally particles for which the unsupervised learning algorithm gave at least two comparable membership probabilities (e.g. identified large probabilities of being in both fluid and FCC). Note that the method presented above requires, in general, prior knowledge of the phases to be expected in the system under analysis. Moreover, additional simulations of such phases must be performed in order to (i) identify the relevant BOPs and (ii) define separations between the distinct particle environments. Both tasks, (i) and (ii), are autonomously performed by our unsupervised-learning method based only on the vectors of BOPs evaluated from the snapshot under study.
Regarding the identification of the relevant BOPs, i.e. task (i), in the following section we present how such information can be extracted from the trained autoencoder.

Learning from the autoencoder
As discussed in section II B 2, several methods to assess the relative importance of input variables in neural network models are available. Here, we employ the input perturbation and the improved stepwise methods in order to understand which BOPs were considered to be the most relevant by the autoencoder for the system in Fig. 2. The relative importance of the BOPs evaluated with these methods is shown in Fig. 6.
Only a small subset of three BOPs is found to be relevant and, as expected,q 6 (RI∼ 78%) andq 4 (RI∼ 3%) are part of it. Interestingly however,q 8 , which to our knowledge has never been used in literature, appears to be more important FIG. 6. Relative importance of the BOPs for the system in Fig. 2 assessed with the input perturbation and the improved stepwise methods. The input perturbation method is applied with two different amounts of white noise: 10% and 50% of the input, respectively.
(RI∼ 19%) thanq 4 . To understand why this is, we evaluated theq 8 distributions in the FCC, HCP and fluid hard-sphere phases from several snapshots (see Fig. 7). Such distributions are very similar to those obtained forq 6 , in the sense that they show a clear separation between the fluid and the crystal phases and only a small overlap between the two crystals. If we now go back to the snapshot shown in Fig. 2f, which is roughly half fluid and half crystal, then it is easy to understand whyq 4 has a lower relative importance thanq 6 and q 8 .

B. Grain boundaries
We now consider a snapshot of a system with FCC crystalline domains separated by grain boundaries, depicted in  (10) with σ the particle diameter, β ε = 40 the energy scale, and β = 1/k B T , where k B is the Boltzmann constant and T is the temperature. More details about the simulation can be found in Ref. 5.
The results of the unsupervised learning algorithm are summarized in Fig. 8. Specifically, Fig. 8b shows the twodimensional projection of the vectors Q(i) found by the encoder and the results of the clustering performed in this space. Our method identifies two distinct particle environments, corresponding to particles within the grain boundaries and within the FCC crystalline domains. Note that the particles in the grain boundaries appear disordered and fluid-like. This identification is used to colour the particles in Figure 8a. The most relevant BOPs in this system according to the autoencoder analysis areq 6 (RI∼ 78%) andq 8 (RI∼ 19%), which are indeed those whose distributions show the largest separation between the fluid and crystal phases.

C. Hard cubes
The systems examined so far were all characterized by isotropic interactions between their constituents. As a further test of the performance and generality of our method, we now consider a snapshot of a system of hard cubes with edge length σ (see Fig. 9a), obtained from an event-driven molecular dynamics simulation (EDMD) in the canonical ensemble 39 . The simulation was performed with N = 64000 particles starting from a simple cubic (SC) crystal configuration at a number density in the fluid-crystal coexistence region, ρσ 3 = 0.475. More details on the simulation can be found in Ref. 39.
The two-dimensional projection of the vectors Q(i) found by the encoder and the results of the clustering performed in this space are shown in Fig. 9b, while the final classification is presented in Fig. 9a. In agreement with the standard order parameters used in Ref. 39, the unsupervised learning method identifies two distinct particle environments, corresponding to the fluid and SC crystal phases. From the autoencoder analysis we found that the most relevant BOPs for this system arē q 6 (RI∼ 48%),q 4 (RI∼ 36%) andq 8 (RI∼ 16%).

D. Binary mixture
After having considered single-component systems with both isotropic and anisotropic interactions, we now examine a binary mixture of large (L) and small (S) spheres of diameters σ L and σ S , respectively, with a size ratio σ S /σ L = 0.78 and a stoichiometry N s /N = 2 3 . The particles in this system interact via the WCA potential, U αγ (r), between species α = L, S and γ = L, S βU αγ (r) =    4β ε σ αγ r 12 − σ αγ r 6 + 1 4 , r σ αγ ≤ 2 1/6 0, r σ αγ > 2 1/6 (11) where σ αγ = (σ α + σ γ )/2 and β ε is the energy scale. The snapshot considered here, depicted in Fig. 10a, was obtained from a MC simulation in the isothermal-isobaric ensemble (constant number of particles N, pressure P and temperature T ) with N = 8073 particles, β ε = 5 and β Pσ 3 L = 24.2, and shows a coexistence between the MgCu 2 Laves phase and the fluid phase. More details about the simulation can be found in Ref. 40.
Recall that, since we are dealing with a binary mixture, we describe the local environment of each particle i The results of the unsupervised learning classification are summarized in Fig. 10. Specifically, Fig. 10b shows the two-dimensional projection of the vectors Q(i) found by the encoder and the results of the clustering performed in this space. Our method identifies three distinct particle environments, corresponding to the large (L) and small (S) particles in the MgCu 2 Laves phase and the particles in the fluid phase. Note that since large and small particles in the fluid phase appear equally disordered, the algorithm groups them together in the same cluster. This identification is used to colour the particles in Figure 10a.
The relative importance of the BOPs obtained from the autoencoder analysis is shown in Fig. 11. Interestingly, the BOPs evaluated considering all the nearest neighbors of the particles are not found to be relevant for this system, with the only exception ofq 6 (RI∼ 2%). The largest variations in the environments are instead found in three of the BOPs evaluated considering only the nearest neighbors of the same species as the reference particle, specificallyq ss 6 (RI∼ 70%), q ss 8 (RI∼ 15%), andq ss 4 (RI∼ 11%).

E. Nucleation and crystal growth
Finally, we examine the nucleation and crystal growth of a single-component system of particles with diameter σ , interacting via the WCA potential (Eq. 10). Note that the nucleation and phase behavior of this system has been extensively studied in Ref. 41. Here, we performed a MC simulation in the isothermal-isobaric ensemble with N = 2048 particles, β ε = 40 and β Pσ 3 = 30. Six snapshots from this simulation, showing the transition from the fluid to the crystal phase, are depicted in Fig. 12.
We started our structural analysis by considering all snapshots together. For all particles, we evaluated the vectors Q(i) which we used as the input of the unsupervised learning al- gorithm. Performing a single analysis for all the snapshots in Fig. 12 guarantees that: (i) a sufficient statistics of the two environments, i.e. fluid and crystalline, is included in the analysis, and (ii) the same clustering is applied to each snapshot, allowing a quantitative comparison between them.
The two-dimensional projection found by the encoder and the results of the clustering performed in this space are shown in Fig. 13. This identification is used to colour the particles in Figure 12. As expected, the unsupervised learning method identifies two distinct particle environments, corresponding to the fluid and crystal phases. In order to quantitatively compare the results with the standard classification method presented in Sec. III A 2, we evaluated the fraction of crystalline particles identified in the six snapshots. Note that, since we employ a soft clustering technique, this requires first to assign each particle to the cluster (crystal or fluid) with the largest membership probability. The results obtained with the two methods are presented in Tab. I and are in excellent agreement.
One of the reasons behind performing a single analysis for the six snapshots in Fig. 12 was to include sufficient statistics of both the fluid and crystalline environments. Our unsupervised learning method consists of a two-steps analysis: first the autoencoder finds a low-dimensional projection encoding the features with the largest variations within the input data,  To obtain a better estimate of what 'sufficient statistics' means for this system, we performed a separate analysis of each of the snapshots in Fig. 12. For snapshots (b), (c), (d) and (e) we found very similar results to the previous analysis, while, as expected, for snapshots (a) and (f), where only a very small fraction of particles is in one of the phases, we found a different classification. As an example, we report in Fig. 14 the results obtained for snapshot (a). Specifically, in Fig. 14b we show the two-dimensional projection found by the encoder and the results of the clustering performed in this space. Note that this projection is different from the one presented in Fig.  13, as the autoencoder is trained on a different data set with different characteristics. Additionally, in Fig. 14a particles are colored according to this classification. Again, the unsupervised learning identified two distinct environments, that we associate with crystalline and fluid-like particles. However, the amount of crystalline order is much larger compared to the previous classification: about 20% of the particles are classified as crystalline (in the previous analysis it was only 2%). Interestingly, if we look closer at the snapshot in Fig.  14a, we find that the particles recognized as crystalline have indeed a higher local order than in a standard disordered fluid, meaning that the unsupervised learning classification is still reasonable. This has been seen before in nucleation studies. For instance, in Ref. 42, where hard-sphere nucleation was studied at a pressure of β Pσ 3 = 17, slightly different tuning of the order parameter resulted in significantly different results for the size of the largest crystalline cluster in the system (from ∼ 30-100). Nonetheless, the different order parameters all predicted essentially the same nucleation rate.  Fig. 12 onto the 2-dimensional space found by the encoder. Colors represent the distinct environments identified by the clustering.

IV. CONCLUSIONS
In summary, we have introduced a simple, fast, and easy to implement unsupervised learning algorithm for recognizing local structural motifs in colloidal systems. This algorithm makes use of standard BOPs to describe local environments, an autoencoder for dimensionality reduction, and GMMs for clustering the results. We have applied it to a wide variety of systems, ranging from simple isotropically interacting systems (hard spheres, WCA particles) to binary mixtures, and even anisotropic hard cubes. In all cases, the algorithm performed very well, and we were able to identify local environments to a similar precision as "standard" -manually-tuned and system-specific -order parameters.
Moreover, we exploited the analytical mapping defined by the autoencoder to extract extra information on the systems analyzed. Specifically, in all cases we could identify the relevant symmetries underlying the main differences among the distinct particle environments found in the system. Interestingly, in the binary system we studied, this analysis revealed that the same species BOPs were the most important for distinguishing the different particle environments. Finally, in the last example on nucleation and crystal growth, we also explored the possible difficulties one can encounter when only a very small fraction of particles is in one specific environment, and we showed how including more snapshots, i.e. more statistics, could benefit the results of the analysis in such cases.

ACKNOWLEDGMENTS
We would like to thank Frank Smallenburg, Gabriele Maria Coli, and Berend van der Meer for providing us with some of