PCA for materials data · Dimensionality reduction

How can we see trends
in a materials dataset?

Begin with 5,205 thermoelectric observations and discover projection, variance and principal components.

Graduated glass cylinders with measurement scales.
Photo: CHUTTERSNAP / Unsplash · CC0 source

In the SHAP lesson, I explained how we can connect composition with the properties of thermoelectric materials using a model. Seeing these relationships can help us prioritize promising compositions, reduce the number of experiments needed, and save cost, energy, and time. Now let us explore a more complex materials dataset with many dimensions and see how PCA can help us recognize its patterns.

Let us start by looking at a few records in the spreadsheet and then plotting the measurements. Follow the numbered steps below: choose 01 — Our materials data to inspect a small part of the dataset, then use Next to move on with me. Keep an eye on the material you choose; we will follow the same observation as each new idea becomes clear.

Would you like to read the whole explanation? Let us follow all eleven steps below ↓

Step 1 of 11

What should we do with all these measurements?

In the SHAP lesson, I explained how we can use a model to connect elemental composition with the properties of thermoelectric materials. You have learnt how SHAP helps us examine which elemental features contribute to the predicted properties.

Seeing these relationships can help us identify promising compositions and prioritize which experiments to carry out. By narrowing the search, we can reduce the number of experiments needed and save cost, energy, and time.

Now let us look at a slightly more complex problem. Imagine opening a spreadsheet of thermoelectric materials. You have compositions, temperatures, Seebeck coefficients, and electrical and thermal conductivities. You want to understand how these observations differ.

Where should we begin? I suggest we first read a few records, then plot something familiar. Choose a composition in the visual. We will keep track of it as we go.

I will use the ESTM dataset accompanying the paper by Na and Chang. You can download the original spreadsheet here.

This real dataset contains 5,205 observations covering 880 formula strings. Each row is a measurement at a stated temperature, so the same formula can appear several times.

If you notice the same formula at the same temperature more than once, do not immediately discard it. The source or specimen may differ. I have retained those records, and you can follow each observation’s original publication link in the visual.

Let us try this together

Let us read a few rows together. Use the Composition selector below the table to choose a material, then use Measurement to choose one of its records. Notice the temperature and the two conductivities; I will plot those conductivities for you when you choose Next.

Composition:

Temperature
K
Seebeck S
μV/K
Electrical σ
S/m
Thermal κ
W/(m·K)
ZT
dimensionless

Loading p5.js and the thermoelectric measurements…

Inspect your chosen observation

Let us follow the whole story

You can read our eleven steps in order here. When you want to try an idea, choose Explore this idea in the visual. I will bring you back to the matching experiment above, with your chosen material still beside us.

01 · Our materials data

What should we do with all these measurements?

In the SHAP lesson, I explained how we can use a model to connect elemental composition with the properties of thermoelectric materials. You have learnt how SHAP helps us examine which elemental features contribute to the predicted properties.

Seeing these relationships can help us identify promising compositions and prioritize which experiments to carry out. By narrowing the search, we can reduce the number of experiments needed and save cost, energy, and time.

Now let us look at a slightly more complex problem. Imagine opening a spreadsheet of thermoelectric materials. You have compositions, temperatures, Seebeck coefficients, and electrical and thermal conductivities. You want to understand how these observations differ.

Where should we begin? I suggest we first read a few records, then plot something familiar. Choose a composition in the visual. We will keep track of it as we go.

I will use the ESTM dataset accompanying the paper by Na and Chang. You can download the original spreadsheet here.

This real dataset contains 5,205 observations covering 880 formula strings. Each row is a measurement at a stated temperature, so the same formula can appear several times.

If you notice the same formula at the same temperature more than once, do not immediately discard it. The source or specimen may differ. I have retained those records, and you can follow each observation’s original publication link in the visual.

Explore this idea in the visual ↑

02 · Two properties

Is this plot good enough?

Let us begin with something familiar. I have plotted electrical conductivity, σ, against thermal conductivity, κ. You can now look for a trend, groups, and observations that stand apart.

Follow the highlighted measurement of your chosen material. Where does it sit compared with the others? I have used logarithmic axes because both properties span many orders of magnitude. A difference of one along an axis means a tenfold change in the original quantity.

Before we go further, let me ask you: is this picture enough? Where is the Seebeck coefficient? At what temperature was each point measured?

You also know that a formula is only part of a material’s story. Crystal structure, phases, microstructure, and processing can affect its properties. This file does not explicitly record those details. We should keep that limitation in mind.

The plot helps us compare two properties. Let us see what happens when we try to include more of the information we do have.

Explore this idea in the visual ↑

03 · A third property

Can a third axis help us?

You may have thought of adding a third axis. Let us try it. I have added the Seebeck coefficient, S. Rotate the plot and keep an eye on your selected observation.

Some points that overlapped in two dimensions may separate now. We can inspect three quantities together.

But we have used all three spatial directions. We still have temperature and the chemical recipe to consider.

What should we do when there are more than three variables? We could make more plots, but then we would have to follow the relationships across all of them.

Explore this idea in the visual ↑

04 · Too many dimensions

We have too many dimensions to see at once.

Our file records six numerical quantities: temperature, Seebeck coefficient, electrical conductivity, thermal conductivity, power factor, and ZT. Power factor and ZT are related to the other properties, so these are not six independent quantities.

Composition adds many more dimensions. I have converted each formula into atomic fractions, with one coordinate for each of the 65 elements present in the collection.

Each row here is a composition. Each column is an element. You can inspect a chemical recipe, but it is difficult to follow how many fractions change together across all the rows.

We could keep making pairwise plots. For 65 coordinates, that would mean 2,080 pairs. We need a simpler way to bring the main patterns into view.

These 65 fractions add to one. If you know 64 of them, the last is fixed. So 65 coordinates do not mean 65 independent directions. I keep temperature separate from the chemical map: heating a sample should not move its composition.

Explore this idea in the visual ↑

05 · Try a new axis

What do I mean by a direction in the data?

Let us return briefly to the conductivity plot. Moving to the right means a higher electrical conductivity at the same thermal conductivity. Moving up means a higher thermal conductivity at the same electrical conductivity.

Moving diagonally means both quantities change together. That is what I mean by a direction in this plot: a particular combination of changes in the quantities. It is not a direction inside a crystal.

I have now centred and standardized the logarithms of the two conductivities, so their numerical scales are comparable. I have subtracted each column’s mean and divided by its standard deviation. We are still using the real measurements.

Rotate the orange axis through the centre. I have connected your chosen observation to its projection on that axis. Its projected position is one new value combining both original quantities.

You can see the projected observations spread out or crowd together as you turn the axis. Which view seems to preserve more of the differences? Let us pause before choosing a direction and understand how we measure that spread.

Explore this idea in the visual ↑

06 · Why keep variance?

Why do we want to keep the greatest variance?

I have asked you to preserve variation. Let us first understand what we are trying to keep.

Some observations have similar conductivities and lie close together. Others differ considerably.

Those differences are what we want to examine. If every observation had the same values, there would be no trend to investigate.

Rotate the orange axis. In some directions, projected points crowd together. Measurements that differed in the original plot now look almost identical. Other directions preserve more of their spread.

What does variance measure here?

Find the mean of the projected values. Measure each value’s distance from that mean, square the distances, add them, and divide by the number of observations minus one.

This gives us the sample variance. Its square root is the standard deviation, which sets the width of the shaded band below the plot.

Squaring prevents positive and negative differences from cancelling. It also gives more weight to values farther from the mean.

Here, variance measures spread across the recorded observations. It is not a measure of uncertainty or experimental error.

Why choose the greatest variance?

We want one new value to summarize two coordinates.

Among all possible single axes, the direction with maximum projected variance preserves the largest share of their overall squared spread.

Look at the perpendicular connectors. Those distances represent differences that disappear when we replace each point with its projection.

Maximizing projected variance also minimizes the sum of squared perpendicular distances.

We keep more spread and lose less in this geometric sense.

Try 45° and then 135°. Watch how the projected values spread out or crowd together, and compare the variance kept with the variance left out.

How does that help us see a materials trend?

If the two conductivities tend to increase together, the observations may spread along a sloping band.

An axis along that band lets us follow their shared change with one coordinate. An axis across it compresses much of that pattern.

With many elemental fractions or measurements, we cannot see the full arrangement directly. The same calculation can help us find combinations along which the observations differ most.

I would not assume that the greatest variance is always the most important materials information. A small dopant change can matter physically. Outliers, measurement conditions, and scaling can also influence the result.

We use variance to construct a summary, then materials knowledge to interpret it.

Explore this idea in the visual ↑

07 · What is a component?

Why call it a principal component?

When you rotated the axis, you changed the combination of the two quantities. Some combinations retained more variation than others.

The direction retaining the greatest variance defines the first principal component, PC1. This is the P: we call it principal because we choose it first, to capture the greatest variance.

What is the C? A component is the new quantity we calculate by combining the original variables. Each observation has a value on it, called its score. Follow your highlighted point to see its score on PC1.

We can then find a second component, PC2, perpendicular to PC1. It captures the most remaining variation.

The A stands for analysis: finding these components, ordering them by variance, and assessing how many to keep. Together, this is principal component analysis, or PCA.

With two variables, both components retain all their variation. Keeping only the first component gives us a simpler description, but loses some detail. Now let us use the same idea to make a simpler picture of our 65 chemical coordinates.

Explore this idea in the visual ↑

08 · PCA of chemistry

Let us return to all 65 chemical coordinates.

We cannot draw 65 mutually perpendicular axes, but the calculation can still find combinations of all 65 elemental fractions. I have kept the first two components so that we can plot them.

Find your chosen composition again. Each of its two coordinates is now a score calculated from the whole chemical recipe, rather than a single element.

Look at PC1. Its largest positive coefficient is for Te; large negative coefficients include Se and Cu. The colours show Te fraction, helping us see part of that pattern. Other fractions also contribute.

We can inspect the component coefficients to understand how the new coordinates were constructed.

This is a pattern of chemical variation among the records. It does not show a physical direction, a crystal structure, or a recipe for improving performance.

PC1 and PC2 retain 33.5% of composition variance. We will check the information left out shortly.

Explore this idea in the visual ↑

09 · Explore properties

Do chemical patterns follow property patterns?

Now we can ask the materials question: does a pattern in composition correspond to a pattern in measured properties?

I have kept the chemical positions fixed. Change the colours between electrical conductivity, thermal conductivity, Seebeck coefficient, and ZT. What changes do you notice?

A change in composition can alter carrier concentrations, bonding, or scattering. It may also change the phases or crystal structure. The property depends on the resulting material and its conditions, not just its elemental fractions.

Try narrowing the temperature range, then read the original measurements of a region that interests you. Does the region with high electrical conductivity also look promising in ZT? What happens when you examine thermal conductivity?

Our map can suggest a question; we still need materials knowledge and source information to investigate it.

Explore this idea in the visual ↑

10 · Check the loss

How much information have we left out?

Our two-dimensional chemical map retains 33.5% of composition variance. The remaining 66.5% lies outside this picture.

Let us check what that means. Switch from PC1–PC2 to PC1–PC3. Do observations that looked close together move apart?

I have also reconstructed your selected material’s fractions using only the two displayed components. Compare that approximation with its actual chemical recipe.

Which details are represented reasonably well? Which differences have we lost?

We should not assume every apparent neighbour is similar in every respect. A small change in a fraction may also matter physically even when it contributes little to the overall variance.

Explore this idea in the visual ↑

11 · Ask your question

What do you want the map to tell you?

So far, we have asked which compositions have similar chemical recipes. We can ask a different question: which observations have similar measured behaviour?

For this map, I have used T, S, log₁₀ σ, and log₁₀ κ, with each column centred and standardized. We will work through the full calculation in Part 4.

The first two components retain 67.5% of standardized measurement variance. I have coloured the map by ZT, which was not used to position the points.

Find your chosen observation once more. Its neighbours may have changed because we changed the question and the variables.

You have now learnt how PCA constructs new axes, why we keep the leading components, and why we must check what the reduced view leaves out.

Let me leave you with one question: you find an observation near one with high ZT. Is that enough to select it for further investigation without checking its original measurements?

Use the map to find a pattern. Return to the measurements, check their conditions and sources, and decide what you would investigate next.

You may now be wondering how I found these axes. Let us carry your chosen observation into the next part, where we will connect the directions you have seen to eigenvectors and eigenvalues.

Explore this idea in the visual ↑

Where do we go from here?

You have seen why we need a smaller view, how projection loses information, and why we choose the direction of greatest variance first. Now I would like to show you how we find those directions. We will start with a small counterexample, so you can see why subtracting the means matters.

We will keep following the observation you selected. First we will understand the axes, then check our scaling choices, and finally work out a score ourselves.

Continue to Part 2: How do we find the new axes? →

If you came from my Fourier transform lesson, we are changing the question: instead of choosing fixed waves, we will find directions from the variation in our observations. When you are ready to see how the numbers fit together, I will guide you through the SVD calculation using these same thermoelectric records. You can continue through Parts 2–4 first; there is no need to rush the ideas.

Our data comes from Na & Chang (2022), npj Computational Materials 8, 214. Original ESTM spreadsheet · Observation CSV · Reproduce the calculation. This lesson explores the released data with PCA; it does not reproduce the authors’ SIMD model.

Help me keep these tutorials going

If this tutorial helped you, you can support the time I spend creating examples and checking the code.

Support is voluntary. My tutorials remain freely available.