PCA, t-SNE, and UMAP for Geoscience Data
Learning objectives
- Say what a principal component is: a weighted sum of the logs, along the direction they vary most together, at right angles to the others
- Find the components as the eigenvectors of the logs' covariance, their variances as its eigenvalues, and check that the eigenvalues sum to its trace
- Read a scree plot and a component's loadings, and say what the first two components of the six logs part
- Explain why the logs are standardized before PCA, and what PCA in raw units finds instead
Fewer Axes Than Logs
Six logs that measure one rock move together: neutron and sonic both rise with porosity, and density falls with it. Principal component analysis (PCA) gives the logs new axes, each a weighted sum of them at right angles to the others: the first along the direction in which the samples vary most, the next along the most that is left, and so on. On the six standardized logs of the Ogbon field's nine wells the first axis carries 0.659 of the variance and the first two carry 0.912: two numbers say most of what the six logs say. The axes are the eigenvectors of the logs' covariance and the variances along them its eigenvalues, which sum to its trace. PCA reads a variance in whatever unit it is given, so the logs are standardized first: in raw units the first axis is gamma ray.
The Data
The data are the book's own learning set: Ogbon-1, the Petrophysics book's well, and eight hypothetical appraisal wells of the book's field, each 1201 samples every 0.5 ft, 10809 in all, logged by Ogbon-1's own build and the book's own tool model, all synthetic. The six logs are gamma ray (API), density (g/cc), neutron (v/v), sonic (us/ft), log10 of deep resistivity and PEF (b/e). Each is standardized over all 10809 samples, to mean 0 and standard deviation 1, so a standardized log has no unit. Lithology, from the generator's beds, colours the plates; PCA never sees it.
The Geometry
Plate (a) draws three of the logs, standardized, in three dimensions. Density, neutron and sonic fill a stretched ellipsoid, not a ball: across the nine wells neutron and sonic correlate at 0.95, and density and neutron at . PCA finds that ellipsoid's own axes, and its longest carries 0.864 of the three logs' variance. Gamma ray, density and PEF, which see the rock's minerals more than its pores, fill a rounder cloud: their first axis carries 0.617. Turn the plate: along the long axis the cloud is a line, across it a disc.
Eigenvalues and the Trace
With the centred logs as the rows of , samples by logs, the covariance is , and each component solves . The kernel finds all six at once by the Jacobi method, a sequence of rotations that clears the covariance's off-diagonal terms. For the six standardized logs the eigenvalues are 3.953, 1.519, 0.333, 0.117, 0.042 and 0.036. They sum to 6, the trace: each standardized log brings a variance of 1, and the components share the six out among them. PC1's share is 3.953 over 6, 0.659. The scree plot, plate (b), shows how fast they fall: after the second the other four carry 0.088 between them.
Reading the Loadings
A component's loadings are its weights. PC1 weighs gamma ray 0.303, density , neutron 0.485, sonic 0.487, log10 RT and PEF . A sample scores low on it when it is dense, clean, resistive and high in PEF, and high when it is porous or shaly: on every ninth sample the tight limestone scores on average and the shale 1.57. PC2 weighs gamma ray 0.617, density 0.435 and PEF 0.615 together, and parts the sandstone, on average, from the shale, 1.27, and the limestone, 1.07. Plate (d) draws every ninth sample on the two: the three rocks fall apart, though PCA was never told them. A component's sign is arbitrary; the kernel makes each vector's largest weight positive.
Scale First
Left in their units, the logs' variances are numbers in different units. Gamma ray's standard deviation across the nine wells is 42.8 API, density's 0.105 g/cc, and the covariance cannot know that one API is not one g/cc. In raw units PC1 carries 0.957 of the variance and weighs gamma ray 0.978: it is gamma ray, ranked first for the size of its unit. Standardizing gives every log the same variance to offer, so the components measure how the logs move together, not how big their numbers are.
What Is Left
The last component carries 0.006 of the variance: a combination of logs that hardly varies at all. It weighs neutron 0.737 against gamma ray and density 0.373, because the build makes neutron from the porosity that density reads and the shale that gamma ray reads, and only the tool's noise is left along it. Dropping the last components loses little; it is how PCA compresses.
t-SNE and UMAP
PCA is linear: its axes are straight lines through the cloud, and two of them keep the large distances between samples well. t-SNE draws a map instead, a plane on which each sample keeps its nearest neighbours, at the cost of the large distances; it is Section 11.2's figure. UMAP is another method that builds a map from each sample's neighbours; this book does not compute it, and says no more about it.
What Comes Next
Section 11.2, the chapter's workshop, maps 600 samples of the same six logs with t-SNE, and measures what its distances keep and lose against PCA's.