Sub topic 7
Building a map from similarity judgments with MDS
This chapter shows how to turn pairwise "how different are these two brands?" judgments into a two-dimensional perceptual map. It uses multidimensional scaling (MDS). I assume you have read the earlier chapters on choosing a competitor set and collecting perception data. I also assume basic Python and pandas, and that you know what a rating scale and an average are.
Why use similarity judgments
The previous approach, attribute ratings with PCA, asks customers to score each brand on attributes you chose in advance. That has one weakness: you decide which dimensions matter before you see the data. If customers compare brands on something you left off the list, such as "feels trustworthy", the map cannot show it.
Similarity judgments avoid this. You show respondents two brands and ask how similar or different they are. Respondents use whatever criteria they naturally use, and you never name the criteria. MDS then finds a layout of points whose distances match those judgments as closely as possible.
| Question | Attribute ratings with PCA | Similarity judgments with MDS |
|---|---|---|
| What does the respondent do? | Rates each brand on listed attributes | Judges how different each pair of brands is |
| Who chooses the dimensions? | You, through the attribute list | The respondents, implicitly |
| Can you name the axes directly? | Yes, from loadings | Not directly. You must interpret them afterward |
| Survey burden | Grows with brands times attributes | Grows with the number of brand pairs |
| Main risk | Missing attributes | Respondent fatigue and hard-to-name axes |
What MDS does
MDS takes a matrix of dissimilarities. Entry (i, j) is the distance customers perceive between brand i and brand j. It places one point per brand in a space with a chosen number of dimensions, here two. It adjusts the positions until the distances between points are as close as possible to the input dissimilarities.
The measure of how far the layout is from the input is called stress. Lower stress means a better fit. A perfect fit has stress 0.
MDS has three properties you need to know before interpreting a map:
- Only relative distances are meaningful. The solution can be rotated, flipped, or shifted without changing any distance. Dimension 1 is not "more important" than dimension 2 just because it is on the horizontal axis.
- There are no loadings. PCA gives you attribute weights for each axis. MDS does not, because it never saw attributes.
- The result depends on the starting layout. The algorithm is iterative and can settle in a poor local solution. Running several random starts (
n_init) guards against this.
From survey rows to a dissimilarity matrix
Survey tools usually export pairwise judgments as one row per respondent per pair. You must average these into a symmetric matrix with zeros on the diagonal, because a brand is identical to itself.
Suppose you asked each respondent to rate every pair on a 1 to 7 dissimilarity scale, where 1 means "almost the same" and 7 means "completely different". The code below builds the matrix from two respondents' answers. A real study would have many more respondents.
import numpy as np
import pandas as pd
brands = ["Brand A", "Brand B", "Brand C", "Brand D"]
# One row per respondent per brand pair (1 = very similar, 7 = very different).
responses = pd.DataFrame(
{
"respondent": [1] * 6 + [2] * 6,
"brand_i": ["Brand A", "Brand A", "Brand A", "Brand B", "Brand B", "Brand C"] * 2,
"brand_j": ["Brand B", "Brand C", "Brand D", "Brand C", "Brand D", "Brand D"] * 2,
"dissimilarity": [2, 6, 5, 5, 5, 1, 2, 6, 5, 6, 5, 2],
}
)
# Average across respondents for each pair.
pair_means = responses.groupby(["brand_i", "brand_j"])["dissimilarity"].mean()
# Fill a symmetric matrix. The diagonal stays at 0.
matrix = pd.DataFrame(0.0, index=brands, columns=brands)
for (i, j), value in pair_means.items():
matrix.loc[i, j] = value
matrix.loc[j, i] = value
print(matrix)The result matches the matrix used in the next example. Brand A and Brand B average 2.0, which means customers see them as close. Brand A and Brand C average 6.0, which means customers see them as far apart.
Fitting the map
Pass the matrix to scikit-learn's MDS with dissimilarity="precomputed". This tells it the input is already a distance matrix, not raw feature columns.
import numpy as np
from sklearn.manifold import MDS
brands = ["Brand A", "Brand B", "Brand C", "Brand D"]
# Average perceived dissimilarity between brand pairs (0 = identical).
dissimilarity = np.array(
[
[0.0, 2.0, 6.0, 5.0],
[2.0, 0.0, 5.5, 5.0],
[6.0, 5.5, 0.0, 1.5],
[5.0, 5.0, 1.5, 0.0],
]
)
mds = MDS(n_components=2, dissimilarity="precomputed", n_init=4, random_state=0)
coords = mds.fit_transform(dissimilarity)
for brand, (x, y) in zip(brands, coords):
print(f"{brand}: ({x:.2f}, {y:.2f})")
print("stress:", round(mds.stress_, 3))Each argument matters:
n_components=2asks for a two-dimensional map.dissimilarity="precomputed"tells MDS that the matrix you pass is the distance matrix.n_init=4runs four different random starts and keeps the best one. Use more starts for larger maps.random_state=0makes the result repeatable. The signs and orientation of the axes can still differ between scikit-learn versions or settings.
In this data, Brand A and Brand B should land close together, and so should Brand C and Brand D. The two pairs should sit far apart. That is the structure in the matrix.
Reading stress properly
The stress_ value that scikit-learn reports is a raw sum of squared differences. It depends on the scale of your data, so a stress of 12 on a 1 to 7 scale is not comparable to a stress of 12 on a 0 to 100 scale. It also gets larger when you have more brands.
A scale-free alternative is Kruskal's stress-1. It is the square root of the squared misfit divided by the squared input distances. You can compute it from your own coordinates:
import numpy as np
from scipy.spatial.distance import pdist, squareform
def kruskal_stress_1(dissimilarity, coords):
"""Scale-free stress: 0 is a perfect fit, larger is worse."""
fitted = squareform(pdist(coords))
misfit = ((fitted - dissimilarity) ** 2).sum()
return float(np.sqrt(misfit / (dissimilarity ** 2).sum()))
# Uses `dissimilarity` and `coords` from the previous example.
print("Kruskal stress-1:", round(kruskal_stress_1(dissimilarity, coords), 3))A common rule of thumb from Kruskal's original guidance reads the value like this:
| Stress-1 | Fit |
|---|---|
| 0.20 or higher | Poor |
| About 0.10 | Fair |
| About 0.05 | Good |
| 0.025 or lower | Excellent |
Treat these as rough guides, not thresholds. Fit also depends on how many brands you map. A small map with few points can reach low stress easily, so a low value from four brands is weaker evidence than the same value from twelve.
Choosing the number of dimensions
You can fit MDS in one, two, three, or more dimensions. Stress always falls as you add dimensions, so the lowest stress is not the goal. A common method is to fit 1, 2, 3, and 4 dimensions, plot stress against dimension count, and look for an elbow where adding another dimension stops helping much. Two dimensions are convenient because you can draw them. If the elbow is at three, a flat two-dimensional map will distort distances, and you should say so when you present it.
Metric and non-metric MDS
The call above is metric MDS. It tries to reproduce the actual dissimilarity values. That is reasonable when respondents rate on a numeric scale and you believe the gaps between scale points mean something.
Non-metric MDS only tries to reproduce the rank order of the distances. If the largest dissimilarity is between A and C, then A and C should be farthest apart on the map. The exact numbers do not matter. This is safer when judgments are rankings or when you doubt that a "6" is twice as different as a "3". scikit-learn supports this through the metric setting, but the parameter names have changed across recent versions, so check the documentation for your installed version.
Naming the axes without loadings
Because MDS never sees attributes, you have to work out what the axes mean. Two practical methods:
- Look at the extremes. Find the brands at the two ends of each axis and ask what they have in common that the brands at the other end lack. If the budget brands sit left and the luxury brands sit right, you have a price or prestige axis.
- Fit attributes onto the map afterward. If you also collected attribute ratings, regress each attribute's brand averages on the two coordinates. The regression coefficients give each attribute an arrow direction on the map. Attributes that point the same way as an axis help you name it. This is sometimes called property fitting.
Be cautious with names. An axis is a direction in which brands differ, and several unrelated attributes can line up along it.
Common errors
- Forgetting the symmetric matrix. If entry (A, B) differs from entry (B, A), the matrix is invalid input. scikit-learn may not warn you clearly, so check with
np.allclose(m, m.T). - Mixing similarity and dissimilarity. MDS needs larger numbers for brands that are farther apart. If your survey scale says 7 means "very similar", convert it first, for example with
8 - ratingon a 1 to 7 scale. - Too many pairs for respondents. The number of pairs is n(n-1)/2. Eight brands give 28 pairs, and ten give 45. Long pairwise surveys lead to straight-lining, where respondents give the same answer to everything. Split pairs across respondents or limit the competitor set.
- Reading small distances as meaningful. With noisy data, a small gap between two brands may disappear with a different sample. Check stability by bootstrapping respondents, rerunning MDS, and seeing whether the same brands stay together.
- Comparing maps from different runs directly. Two separate fits can differ by rotation or reflection. To track positioning over time, align them first, for example with Procrustes rotation, and do not compare raw coordinates.
Exercises
Exercise
Your dissimilarity matrix comes from a survey where respondents rated each pair from 1 (very similar) to 7 (very different). A colleague instead used a scale where 1 means "very different" and 7 means "very similar" and ran MDS on the averages without changing them. What goes wrong, and how do you fix it?
Show answer
MDS treats larger numbers as larger distances, so brands customers see as alike would be placed far apart and different brands close together. The map would be inverted in meaning. Convert the scale to a dissimilarity first, for example dissimilarity = 8 - rating on a 1 to 7 scale, and set the diagonal to 0 before fitting.
Exercise
You map 12 brands in two dimensions and get Kruskal stress-1 of 0.22. Stress in three dimensions is 0.11 and in four dimensions is 0.09. What would you conclude about the number of dimensions, and what caveat would you attach to a two-dimensional chart?
Show answer
The big drop from two to three dimensions and the small drop from three to four suggest an elbow at three, so a three-dimensional solution describes the judgments better. A two-dimensional chart with stress 0.22 is a poor fit, so some distances on it are distorted. If you present it, state the stress, avoid reading small distances as meaningful, and consider showing the other dimension pairs.