Unsupervised Learning

The Data Science unit on finding structure in data without labels, worked on the 178 wines of the wine data with the cultivar hidden, the 272 eruptions of the Old Faithful geyser and nine mental ability tests taken by 301 children in 1939. Clustering by centers, by merging and by density; outliers as points in sparse regions; principal components as eigenvectors of the correlation matrix; and factor analysis as a model of correlations, each checked without the labels that supervised learning relies on.

Unsupervised learning finds structure in data that has no outcome to predict: groups of similar instances, dense regions and the points that fall outside them, and a smaller number of underlying dimensions. Its difficulty is the absence of a check. A classifier can be scored against held-back labels; a clustering, an outlier list or a set of components cannot, so every result has to be examined by other means: internal criteria such as the silhouette, stability under resampling, agreement between methods, and finally whether the result means something in the domain.

The unit uses three datasets. The 178 wines of the wine data, described by 13 chemical measurements, carry a cultivar label that is hidden during the analysis and revealed only afterwards to show what was found. The 272 eruptions of the Old Faithful geyser, eruption length and waiting time, fall into two groups with a few eruptions between them. The nine mental ability tests of Holzinger and Swineford, taken by 301 schoolchildren in 1939, have correlations that fall into blocks. Every number in the unit is computed by a script in tools/experiments/data-science/, and each article ends with worked problems that extend it on its own data and with open questions that further experiments could settle.

Articles, in order

  • Introduction to Unsupervised Learning: the setting, and the three families of methods (clustering, outlier detection and dimension reduction) as three questions about where the data are dense. All three are put to the wine data: k-means on raw and standardized measurements, where scaling decides the answer; the silhouette worked by hand; the number of clusters chosen by the within-cluster sum of squares, proved never to rise with more clusters, and by the mean silhouette; a two-dimensional map that keeps the group structure; five isolated wines that the map hides; and stability under resampling, which can rule results out but cannot confirm them.
  • K-Means Clustering: the algorithm and the proof that it converges, from the Academics section's text clustering topic; K-means in Practice covers starting points, choosing $k$ and scaling.
  • Hierarchical Clustering: building a tree of nested clusters by repeated merging under single, complete, average and centroid linkage, also from the Academics section.
  • Detecting Outliers Using DBSCAN: clusters as connected regions of high density, from the definitions of Ester, Kriegel, Sander and Xu (1996), worked by hand on twelve points and applied to Old Faithful, where one eruption is set aside as noise; clusters of any shape; choosing the radius with the sorted k-distance plot, shown to count non-core points rather than noise; DBSCAN with MinPts of 2 proved equal to single linkage; what the processing order can and cannot change; and where a single density threshold fails.
  • Factor Analysis: correlations explained by a few unobserved factors, from Spearman's one-factor model solved by hand on three verbal tests to a maximum likelihood fit of three factors; the conditions the fit satisfies and the likelihood ratio test of the number of factors, which rejects three factors whose residual correlations are all below 0.05; rotation and varimax; factor scores, whose shrinkage and correlations are derived; and the comparison with principal components on the same correlations.
  • Principal Component Analysis: the components derived as eigenvectors of the covariance matrix and through the singular value decomposition, worked by hand for two wine measurements; the proportion of variance explained and the rules for how many components to keep; why the inputs are standardized, shown by recording proline in other units; loadings as correlations and biplots; and the effect of one wrong value.

The order follows the three families. The overview poses all three questions on one dataset. The two borrowed course articles and DBSCAN cover clustering, DBSCAN also covering outliers. Factor analysis and principal components cover dimension reduction; each article compares its method with the other, so the two can be read in either order.

Where the site goes deeper

The Academics section's Text Clustering topic treats clustering in depth for documents: Evaluating Clusterings works the silhouette and the external criteria that need known classes, Clustering Measures Corrected for Chance derives the adjusted Rand index used throughout this unit, Model-Based Clustering and the EM Algorithm fits mixtures with EM, and Linkage Properties of Agglomerative Clustering proves the properties of the linkages. The Statistics unit Multivariate Statistics owns the theory: Covariance Matrices and Quadratic Forms proves the spectral facts behind principal components, The Singular Value Decomposition in Statistics proves that principal components give the closest low-dimensional plane, The Multivariate Normal Distribution supplies the model behind maximum likelihood factor analysis, and Gaussian Mixture Models treats soft clustering with full covariance matrices. Outliers in single variables, the Mahalanobis distance, isolation forests and the local outlier factor are in the Data Exploration unit's Detecting Outliers, and Latent Semantic Indexing applies the singular value decomposition to text.

Several subjects the unit touches would fit a later collection of their own: spectral and mean-shift clustering, density hierarchies such as HDBSCAN, criteria for the number of clusters such as the gap statistic, nonlinear dimension reduction from multidimensional scaling to t-SNE and UMAP, matrix factorizations such as NMF and independent component analysis, and anomaly detection beyond the methods here.

References

  • Ester, M., Kriegel, H.-P., Sander, J., and Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96) (pp. 226–231). AAAI Press. record · 2 pages
  • Hastie, T., Tibshirani, R., and Friedman, J. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction (2nd ed.). Springer. record · 39 pages
  • Holzinger, K. J., and Swineford, F. (1939). A Study in Factor Analysis: The Stability of a Bi-Factor Solution (Supplementary Educational Monographs, No. 48). University of Chicago. record · 2 pages
  • James, G., Witten, D., Hastie, T., and Tibshirani, R. (2021). An Introduction to Statistical Learning with Applications in R (2nd ed.). Springer. record · 39 pages
  • Jolliffe, I. T., and Cadima, J. (2016). Principal component analysis: A review and recent developments. Philosophical Transactions of the Royal Society A, 374(2065), 20150202. https://doi.org/10.1098/rsta.2015.0202 record · 2 pages