Sub topic 8
Naming the Axes from Loadings and Attribute Directions
A PCA map gives you coordinates, but the axes come out labelled "dim1" and "dim2". Those names mean nothing to a marketing team. This chapter shows how to turn the loadings, which describe how each attribute relates to each dimension, into axis names you can defend.
This chapter assumes you can run the PCA example from the previous chapter. It also assumes you know what a correlation is and can read a pandas DataFrame.
What a loading tells you
PCA builds each dimension as a weighted sum of the standardized attributes. The weights are the loadings. A large positive weight means a brand that rates high on that attribute tends to score high on the dimension. A large negative weight means the reverse. A weight near zero means the attribute barely affects that dimension.
In scikit-learn, pca.components_ has one row per dimension and one column per attribute. Transpose it to get one row per attribute, which is easier to read.
Be aware that "loading" has two common meanings:
| Quantity | How to get it | Range | Best used for |
|---|---|---|---|
| Component weight (eigenvector) | `pca.components_.T` | Each dimension's weights have squared length 1 | Reproducing the scores |
| Correlation of an attribute with a dimension | Correlate each rating column with the scores | -1 to 1 | Naming axes and explaining them to others |
Correlations are easier to explain. You can say "the dimension correlates 0.95 with premium" and a reader knows what that means. Component weights are on a scale that depends on how many attributes you have. The two usually give the same ranking of attributes, so use either one, but say which.
From loadings to a label
The process has five steps, shown below.
The code below runs the whole workflow on the ratings from the earlier chapter.
import numpy as np
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
ratings = pd.DataFrame(
{
"affordable": [6.1, 5.4, 2.3, 3.0, 4.2],
"premium": [2.0, 3.1, 6.4, 5.8, 4.0],
"innovative": [3.2, 5.9, 5.1, 2.5, 4.4],
"reliable": [5.0, 3.3, 5.6, 6.0, 4.1],
},
index=["Brand A", "Brand B", "Brand C", "Brand D", "Brand E"],
)
scaled = StandardScaler().fit_transform(ratings)
pca = PCA(n_components=2).fit(scaled)
scores = pd.DataFrame(
pca.transform(scaled), index=ratings.index, columns=["dim1", "dim2"]
)
weights = pd.DataFrame(
pca.components_.T, index=ratings.columns, columns=scores.columns
)
# The sign of a PCA dimension is arbitrary.
# Flip each dimension so its largest-magnitude weight is positive.
for dim in scores.columns:
anchor = weights[dim].abs().idxmax()
if weights.loc[anchor, dim] < 0:
weights[dim] = -weights[dim]
scores[dim] = -scores[dim]
# Correlation of each original rating with each dimension's scores.
loadings = pd.DataFrame(
{dim: ratings.corrwith(scores[dim]) for dim in scores.columns}
)
print("Component weights")
print(weights.round(2))
print("\nCorrelation loadings")
print(loadings.round(2))
def describe(dim, cutoff=0.5):
"""Print the attributes that define each pole of a dimension."""
s = loadings[dim]
strong = s[s.abs() >= cutoff].sort_values(key=abs, ascending=False)
high = [a for a, v in strong.items() if v > 0]
low = [a for a, v in strong.items() if v < 0]
print(f"{dim}: high end = {high or 'none'}; low end = {low or 'none'}")
for dim in loadings.columns:
describe(dim)
print("\nVariance explained:", pca.explained_variance_ratio_.round(2))Run it and read the printed describe lines. They tell you which attributes sit at each end of each dimension. Your job is to turn each list into a short, honest name.
Fix the sign first
PCA does not care whether a dimension points left or right. The same data can give you a dimension with all its signs flipped, depending on the library version or a small change in the data. If you skip the sign step, a map you rebuild next quarter can look mirrored, and readers will think brands moved when they did not.
Choosing a cutoff
Treat an attribute as defining a dimension when its correlation loading has an absolute value of about 0.5 or more. Some analysts use 0.4 and some use 0.7. The cutoff is a judgment call, so state it in your report. With only four attributes, as here, most attributes will be strong on one dimension or the other. With 15 attributes you will see a clearer separation between the defining attributes and the rest.
Reading the pattern of loadings
Look at the shape of the loadings before you try to name anything.
| Pattern on one dimension | What it suggests | Naming approach |
|---|---|---|
| Two opposing groups, such as *affordable* positive and *premium* negative | A trade-off between two ideas | Name it as a contrast: "Value vs. premium" |
| Several attributes all positive | A shared theme | Name the theme: "Overall quality" |
| One attribute dominates, the others are near zero | The dimension is basically that attribute | Use that attribute's name |
| Many mid-sized loadings of mixed sign | No clean meaning | Do not force a label. Consider fewer attributes or another method |
Contrast labels work well for positioning because customers do trade price against quality, or tradition against novelty. A pole label such as "Value" on one end and "Premium" on the other tells a manager exactly where to look.
A common pattern is that the first dimension is a general "good or bad" factor. If every attribute is a positive trait, such as quality, trust, and service, and customers like some brands more than others, every attribute will load positively on dimension 1. That is a halo effect. It is real information, but it is a measure of overall liking, not a positioning contrast. Dimension 2 then carries the useful differences.
Attribute directions on the map
Loadings can also be drawn on the map. Each attribute becomes an arrow from the origin. The arrow's direction is the attribute's loadings on the two dimensions. A brand located far along an arrow's direction scores high on that attribute. This chart is called a biplot.
import matplotlib.pyplot as plt
# Reuses `scores` and `loadings` from the previous block.
fig, ax = plt.subplots(figsize=(6, 6))
ax.scatter(scores["dim1"], scores["dim2"])
for brand, row in scores.iterrows():
ax.annotate(brand, (row["dim1"], row["dim2"]), xytext=(5, 5), textcoords="offset points")
# Stretch the arrows so they are visible next to the brand points.
stretch = scores.abs().to_numpy().max()
for attribute, row in loadings.iterrows():
tip = (row["dim1"] * stretch, row["dim2"] * stretch)
ax.annotate("", xy=tip, xytext=(0, 0), arrowprops={"arrowstyle": "->", "color": "tab:red"})
ax.annotate(attribute, tip, color="tab:red", xytext=(3, 3), textcoords="offset points")
ax.axhline(0, color="grey", linewidth=0.8)
ax.axvline(0, color="grey", linewidth=0.8)
ax.set_xlabel("Dimension 1")
ax.set_ylabel("Dimension 2")
ax.set_title("Perceptual map with attribute directions")
plt.show()Read the arrows with these rules:
- Arrows that point the same way describe attributes customers see as going together.
- Arrows that point in opposite directions describe attributes customers see as opposed.
- Arrows at right angles are unrelated on this map.
- A long arrow means the map represents that attribute well. A short arrow means the attribute is mostly carried by dimensions you did not plot.
- To find a brand's rank on an attribute, project the brand's point onto the arrow's line. The arrow's length only shows how well the map captures that attribute. It does not change the ranking.
The stretch factor changes only the arrow lengths, never their directions, so you can pick any scale that looks readable. Mention in the caption that arrows are rescaled.
Checking the label against the brands
A label is a hypothesis, and brand positions test it. After you name a dimension, list the brands from highest to lowest score and ask whether the order matches what you know.
print(scores["dim1"].sort_values(ascending=False).round(2))
print(scores["dim2"].sort_values(ascending=False).round(2))If you call dimension 1 "Value vs. premium" and the brand everyone knows as the luxury leader sits at the "value" end, something is wrong. The usual causes are a sign error, a mislabeled column, or a rating scale that was reversed in the survey.
Naming maps built from similarity data
An MDS map has no loadings, because the input was pairwise dissimilarities, not attribute ratings. To name its axes, add the attributes afterwards. Collect average attribute ratings for the same brands, then for each attribute, fit a regression of the ratings on the two MDS coordinates. The regression coefficients give the arrow's direction, and the fit's R² tells you how well the map captures that attribute. This is often called property fitting. An attribute with a low R² should not be drawn, because the map does not describe it. MDS axes can also be rotated freely, so use the attribute arrows, not the horizontal and vertical directions, to interpret the map.
Common errors
- Naming from one attribute. A dimension is defined by all its strong attributes. If you pick the single largest loading and ignore the second, you can end up with a misleading label.
- Treating the axis as a measured attribute. "Premium-ness" is a name for a combination, not something customers rated.
- Over-reading small loadings. A correlation of 0.3 on a sample of five brands is noise.
- Reading dimension 2 without checking its variance share. If
explained_variance_ratio_shows dimension 2 explains very little, its label describes a small part of the differences between brands. - Forgetting that rotation changes the loadings. Methods such as varimax rotation rearrange the loadings so each attribute loads mainly on one dimension, which makes naming easier. State it if you rotated, because the dimensions are then no longer ordered by variance.
Exercise
You fit PCA on six standardized attribute ratings and print the correlation loadings. On dimension 1, "low price" has -0.91, "luxurious" has 0.88, and "easy to use" has 0.12. Your colleague reruns the analysis and gets +0.91 for "low price" and -0.88 for "luxurious". Has the map changed? What would you label dimension 1, and what should you do so the two runs agree?
Show answer
The map has not changed. The sign of a PCA dimension is arbitrary, so the second run is a mirror image with the same distances between brands. Label dimension 1 as a contrast, "Low price vs. luxury", because the two strong attributes oppose each other. "Easy to use" at 0.12 does not help define it. To make runs agree, apply a fixed sign rule, such as making the largest-magnitude loading positive, to both loadings and scores before plotting.
Exercise
In a biplot, the arrow for "innovative" is long and points up and to the right. The arrow for "traditional" is long and points down and to the left. Brand X sits far up and to the right. What can you say about Brand X, and what can you say about the relationship between the two attributes?
Show answer
Brand X is rated high on "innovative" and low on "traditional", since it lies far along the "innovative" direction and opposite the "traditional" direction. The two arrows point in opposite directions, so customers see the attributes as opposed. Both arrows are long, so the map represents both attributes well.