Comprehensive Study Guide to Unsupervised Learning in Materials Science


Introduction to Unsupervised Learning in Materials Science

Unsupervised learning is a fundamental branch of machine learning where a model identifies patterns, structures, and relationships within a dataset without the guidance of pre-assigned labels or correct output values. In this paradigm, the system is provided solely with input data, often referred to as features, and is tasked with discovering hidden groupings or underlying distributions independently. The primary categories of unsupervised learning include Clustering, which aims to group similar data points using methods such as K-means, hierarchical clustering, and DBSCAN; Dimensionality Reduction, which simplifies complex data by reducing the number of features through techniques like Principal Component Analysis (PCA) or t-SNE; and Density Estimation, which identifies the distribution of data points using Kernel Density Estimation (KDE) or Gaussian Mixture Models (GMM). Additionally, Anomaly Detection is used to identify outliers through algorithms like Isolation Forest, while Association Rules discovery (e.g., the Apriori algorithm) finds hidden relationships between variables. Finally, Representation Learning, often implemented via Autoencoders, focuses on learning the most efficient features or encodings from raw input.

Applications of Unsupervised Learning in Materials Science

In the field of materials science, unsupervised learning serves as a powerful tool for discovering material categories and structure-property relationships without manual labeling. For instance, researchers can cluster materials based on features like band gap, density, formation energy, and electronegativity difference to automatically identify categories such as metals, semiconductors, and insulators. Another significant application is the use of Principal Component Analysis (PCA) to manage high-dimensional datasets containing 20×5020 \times 50 features, including atomic radius, ionization energy, lattice constants, and orbital energies. PCA reduces these features into a 2D or 3D space, enabling the visualization of trends, the identification of hidden correlations, and the removal of redundant features. Furthermore, clustering algorithms like K-means are applied to microstructural analysis using Scanning Electron Microscopy (SEM) or Transmission Electron Microscopy (TEM) images. This automates the quantification of microstructures by separating grain boundaries, phases, and defects, leading to precise measurements of grain size distribution and phase fractions.

Fundamentals of Clustering and Similarity Measures

Clustering is the process of partitioning a dataset into groups, or clusters, such that data points within the same cluster exhibit high similarity, while points in different clusters are significantly dissimilar. It is analogous to sorting objects into groups based on their intrinsic properties without knowing the group names beforehand. In materials science, clustering can autonomously categorize unidentified materials into classes like metals, semiconductors, and insulators based on their physical properties. The logic of clustering relies heavily on the concept of distance as a measure of similarity. The Euclidean distance between two points xx and yy is defined as:

d(x,y)=∑i=1n(xi−yi)2d(x, y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2}

A smaller distance indicates higher similarity between points. A cluster is defined as a set of similar data points, and the central point of that cluster is known as the centroid. The centroid μ\mu of a cluster is calculated as the mean of all points within that cluster:

μ=1N∑i=1Nxi\mu = \frac{1}{N} \sum_{i=1}^{N} x_i

The K-Means Clustering Algorithm

K-means clustering is a widely used unsupervised learning algorithm that partitions a dataset into KK distinct clusters. Each cluster is defined by its centroid, which represents the mean point of the assigned data. The ultimate goal of K-means is to minimize the Within-Cluster Sum of Squares (WCSS), a metric also known as inertia. The algorithm follows an iterative process: it begins by selecting KK random initial centers, assigns every data point to its nearest center, and then updates the centers by calculating the mean of the newly assigned points. This cycle repeats until the algorithm achieves convergence. Mathematically, for a dataset XX and a set of kk random centers μk\mu_k, the algorithm seeks to minimize the WCSS defined by:

J=∑k=1K∑x∈Ck∣∣x−μk∣∣2J = \sum_{k=1}^{K} \sum_{x \in C_k} ||x - \mu_k||^2

where CkC_k represents the set of points belonging to cluster kk. This process effectively minimizes intra-cluster distance while maximizing cluster compactness.

Mathematical Formulation and Optimization in K-Means

The K-means algorithm addresses a non-convex optimization problem through a method known as coordinate descent. The process involves two primary steps: the assignment step and the update step. In the assignment step, the centroids are fixed, and each data point xix_i is assigned to the nearest centroid μk\mu_k by solving:

Sik={1if k=arg minj∣∣xi−μj∣∣2 0otherwiseS_{ik} = \begin{cases} 1 & \text{if } k = \text{arg min}_j ||x_i - \mu_j||^2 \ 0 & \text{otherwise} \end{cases}

Once points are assigned, the update step involves minimizing the objective function for a fixed cluster assignment by updating the centroid. This is achieved by taking the derivative of the WCSS with respect to μk\mu_k and setting it to zero:

∂J∂μk=∂∂μk∑xi∈Ck∣∣xi−μk∣∣2=0\frac{\partial J}{\partial \mu_k} = \frac{\partial}{\partial \mu_k} \sum_{x_i \in C_k} ||x_i - \mu_k||^2 = 0

Solving this results in the new centroid, which is the mean of the points in the cluster:

μk=1∣Ck∣∑xi∈Ckxi\mu_k = \frac{1}{|C_k|} \sum_{x_i \in C_k} x_i

The algorithm is guaranteed to converge when the centroids and cluster assignments no longer change and the objective function stabilizes. This can also be formulated using a matrix approach where the assignment matrix SS is defined such that snk∈0,1s_{nk} \in {0, 1} and ∑k=1Ksnk=1\sum_{k=1}^K s_{nk} = 1. The objective function in matrix form is written as:

J(S,μ)=∑n=1N∑k=1Ksnk∣∣xn−μk∣∣2J(S, \mu) = \sum_{n=1}^N \sum_{k=1}^K s_{nk} ||x_n - \mu_k||^2

While K-means is efficient and deterministic in its steps, it is sensitive to the initial placement of centroids, the presence of outliers, and the scaling of features. It often converges to a local, rather than global, minimum.

Evaluation, Variants, and Limitations of K-Means

Determining the optimal number of clusters (KK) is a common challenge. One popular method is the Elbow Method, where the WCSS (J(K)J(K)) is plotted against different values of KK, and the "elbow" or point where the rate of decrease slows significantly is chosen. Another metric is the Silhouette Score, which evaluates clustering quality based on the intra-cluster distance (aa) and the distance to the nearest neighboring cluster (bb). While K-means is useful for phase grouping, chemical space exploration, and microstructure segmentation, it has notable limitations: it assumes clusters are spherical, struggles with non-linear shapes, is sensitive to noise, and requires a predefined value for KK. To address these, several variants exist: K-means++ for improved initialization, Mini-batch K-means for large datasets, Kernel K-means for non-linear clustering, and Fuzzy C-means for "soft" clustering where points can belong to multiple clusters simultaneously.

Hierarchical Clustering: Agglomerative and Divisive Approaches

Hierarchical clustering builds a multi-level tree structure, or hierarchy, of clusters. Unlike K-means, which partitions data into a fixed number of groups, hierarchical clustering shows the step-by-step grouping of data points, often compared to an alloy classification tree (elements to compounds to alloys). The results are visualized using a dendrogram, where the vertical axis (height) represents the distance between clusters. There are two main types: Agglomerative Clustering, a bottom-up approach that starts with each point as its own cluster and merges them; and Divisive Clustering, a top-down approach that starts with one large cluster and recursively splits it.

Agglomerative (Bottom-Up) Clustering Process and Metrics

Agglomerative clustering begins with nn individual clusters, each containing one data point. The algorithm iteratively finds the two closest clusters, merges them, and updates the distance matrix. This continues until only one cluster remains. The distance between points can be calculated using several norms. The Euclidean distance is standard, but Manhattan Distance (L1L1 distance) is also used, defined as the sum of absolute differences:

d=∑i=1n∣xi−yi∣d = \sum_{i=1}^{n} |x_i - y_i|

Manhattan distance, reflecting a city-block grid movement, is less sensitive to outliers and produces diamond-shaped contours. Another metric is Cosine Distance, which focuses on the orientation (angle) between vectors rather than their magnitude. Cosine similarity is given by:

cos⁡(θ)=x⋅y∣∣x∣∣ ∣∣y∣∣\cos(\theta) = \frac{x \cdot y}{||x|| \, ||y||}

And the cosine distance is defined as dcosine=1−cos⁡(θ)d_{\text{cosine}} = 1 - \cos(\theta). It is scale-invariant and ranges between 00 and 22, making it ideal for high-dimensional sparse data.

Linkage Criteria in Hierarchical Clustering

Linkage criteria define how the distance between two clusters (sets of points) is calculated during the merging process. Single Linkage (Nearest Neighbor) defines the distance as the minimum distance between any two points in different clusters (dsingle=min⁡d(a,b):a∈A,b∈Bd_{\text{single}} = \min {d(a, b) : a \in A, b \in B}). It tends to form long, chain-like clusters and is sensitive to noise. Complete Linkage (Farthest Neighbor) uses the maximum distance (dcomplete=max⁡d(a,b):a∈A,b∈Bd_{\text{complete}} = \max {d(a, b) : a \in A, b \in B}), which results in compact, tight clusters. Average Linkage calculates the mean of all pairwise distances between the two clusters (daverage=1∣A∣∣B∣∑a∈A∑b∈Bd(a,b)d_{\text{average}} = \frac{1}{|A| |B|} \sum_{a \in A} \sum_{b \in B} d(a, b)), providing a balanced approach. Ward’s Linkage aims to minimize the increase in total within-cluster variance (ΔJ\Delta J) upon merging, resulting in spherical clusters similar to those produced by K-means.

Numerical Example of Linkage Calculations

Consider two clusters, AA and BB, with individual data points. To determine the distance between them, distances between all pairs are calculated. For example, if Euclidean distances between pairs are calculated as 7.077.07, 8.498.49, 5.665.66, and 7.077.07, the linkage values would be:

  • Single Linkage: dsingle=min⁡7.07,8.49,5.66,7.07=5.66d_{\text{single}} = \min {7.07, 8.49, 5.66, 7.07} = 5.66

  • Complete Linkage: dcomplete=max⁡7.07,8.49,5.66,7.07=8.49d_{\text{complete}} = \max {7.07, 8.49, 5.66, 7.07} = 8.49

  • Average Linkage: daverage=14(7.07+8.49+5.66+7.07)=7.07d_{\text{average}} = \frac{1}{4} (7.07 + 8.49 + 5.66 + 7.07) = 7.07

For Ward’s Linkage, centroids are calculated first. If the centroid of AA is μ1\mu_1 and BB is μ2\mu_2, the distance between centroids is used to calculate the variance increase:

ΔJ=n1n2n1+n2∣∣μ1−μ2∣∣2\Delta J = \frac{n_1 n_2}{n_1 + n_2} ||\mu_1 - \mu_2||^2

Ward’s method shares the objective function with K-means but is deterministic and does not require centroid reinitialization.

Divisive (Top-Down) Clustering and Splitting Strategies

Divisive clustering starts with the entire dataset in a single root cluster and recursively splits clusters into sub-clusters (C→C1∪C2C \rightarrow C_1 \cup C_2 where C1∩C2=∅C_1 \cap C_2 = \emptyset) until a stopping criterion is met. The goal is to find partitions that minimize intra-cluster variance, effectively solving a K-means problem with K=2K=2 at each step. To split a cluster CC with NN points, common methods include:

  1. K-Means Based Splitting: Solving for two centers μ1,μ2\mu_1, \mu_2 that minimize variant spread.

  2. Maximum Dissimilarity Method: Identifying the two points farthest apart to serve as seeds for new clusters.

  3. Diameter-Based Splitting: Identifying the cluster with the largest diameter, defined as diam(C)=max⁡d(x,y):x,y∈C\text{diam}(C) = \max {d(x, y) : x, y \in C}, and splitting along the maximum spread.

  4. Spectral Splitting: Representing data as a graph where points are nodes. It uses the Laplacian Matrix L=D−WL = D - W (where WW is the similarity matrix and DD is the degree matrix). By solving the eigenvalue problem Lu=λuLu = \lambda u, the data is split based on the second smallest eigenvector, known as the Fiedler vector.

Implementation and Case Study of Divisive Clustering

In divisive clustering, the decision of which cluster to split is typically based on finding the cluster with the maximum variance, maximum diameter, or maximum error. Stopping criteria include reaching a target number of clusters (KK), or when cluster variance or size falls below a specific threshold. While divisive clustering is thorough, it is computationally expensive and splitting decisions are irreversible.

A practical case study involves clustering six materials (Si, Ge, GaAs, Al, NaCl, MgO) based on Band Gap (EgE_g), Density (ρ\rho), and Electronegativity difference (Δχ\Delta \chi).

  • Si: Eg=1.1 eVE_g = 1.1\,eV, ρ=2.33 g/cm3\rho = 2.33\,g/cm^3, Δχ=0.0\Delta \chi = 0.0

  • Ge: Eg=0.7 eVE_g = 0.7\,eV, ρ=5.32 g/cm3\rho = 5.32\,g/cm^3, Δχ=0.0\Delta \chi = 0.0

  • GaAs: Eg=1.42 eVE_g = 1.42\,eV, ρ=5.32 g/cm3\rho = 5.32\,g/cm^3, Δχ=0.4\Delta \chi = 0.4

  • Al: Eg=0.0 eVE_g = 0.0\,eV, ρ=2.70 g/cm3\rho = 2.70\,g/cm^3, Δχ=0.0\Delta \chi = 0.0

  • NaCl: Eg=8.5 eVE_g = 8.5\,eV, ρ=2.16 g/cm3\rho = 2.16\,g/cm^3, Δχ=2.1\Delta \chi = 2.1

  • MgO: Eg=7.8 eVE_g = 7.8\,eV, ρ=3.58 g/cm3\rho = 3.58\,g/cm^3, Δχ=2.3\Delta \chi = 2.3

Calculating the Euclidean distance between Si and Ge:

d(Si, Ge)=(1.1−0.7)2+(2.33−5.32)2+(0−0)2≈3.02d(\text{Si, Ge}) = \sqrt{(1.1 - 0.7)^2 + (2.33 - 5.32)^2 + (0 - 0)^2} \approx 3.02

Calculating the distance between NaCl and MgO:

d(NaCl, MgO)=(8.5−7.8)2+(2.16−3.58)2+(2.1−2.3)2≈1.60d(\text{NaCl, MgO}) = \sqrt{(8.5 - 7.8)^2 + (2.16 - 3.58)^2 + (2.1 - 2.3)^2} \approx 1.60

Using Agglomerative clustering with Ward's linkage, the closest pair NaCl and MgO are merged first into Cluster C1C_1, followed by Si and Ge into C2C_2. Subsequently, GaAs is merged with C2C_2 to form C4C_4. This continues until the desired classification of metals, semiconductors, and insulators is achieved.