What a satellite classifier actually looks at
The last post ended with a land-cover model that takes six numbers for a pixel and returns a class. That leaves an obvious question: which of the six did it use? For an irrigated field the textbook answer is red and near infrared.
The model half agrees. What to make of the other half takes the rest of this post, and it changes how to read any feature-importance chart.
A model small enough to send you
The model in the last post was a random forest of 120 trees, several megabytes of questions, so that page ships finished maps and no model. For this one I wanted the model itself on the page, so that nothing you see is a recording.
So I trained a small neural network on the same scene: Pasco, Washington, as Sentinel-2 saw it on 8 July 2021. Six reflectances go in (blue, green, red, near infrared and two shortwave infrared bands), two layers of sixteen units sit in the middle, and six class scores come out. That is 486 numbers, about four kilobytes. The labels are the same ESA WorldCover map, cut into the same sixteen training blocks and eight held-out ones.
On the held-out blocks it agrees with WorldCover on 75.7% of pixels, against 75.3% for the forest, and it gives the same answer as the forest on 85% of the scene. It is a different model that learned much the same map, which is all I need from it.
Asking which band did it
You cannot remove an input from a network. It has six slots and wants six numbers. What you can do is replace one: swap this pixel’s red for the red of some other pixel in the scene and see how far the answer moves. Do that against 128 pixels drawn at random and average, and you have what the model says when it has not been told this pixel’s red.
Replace all six and you get the answer for a pixel the model knows nothing about. It is 32% built-up, 23% crops, 21% grass, 11% trees, 9% water and 5% bare ground. In other words, roughly what the scene is made of. Every explanation below starts from there. A band’s credit is how many percentage points the chance of the final answer moves when that band’s real value is put back, averaged in a particular way that the next section is about.
The marker starts on the irrigated circle from the last post. The model says crops, 98%. It began at 23%, so the bands had 75 points to hand out between them. Near infrared takes 36, which is the textbook half: a healthy leaf throws near infrared straight back, and nothing else in the scene is that bright there.
Then blue takes 31. And red, the band chlorophyll absorbs, the band half of every vegetation index is built on, gets minus 4.
The other places are worth a visit before I explain that. The dry field is a pixel WorldCover calls cropland and the model calls grass, at 97%. In the last post I guessed that the model was reacting to the field being dry on the one afternoon it was shown. Here that guess can be checked: almost all the credit, 47 points, goes to the first shortwave band, the one that brightens as leaves and soil lose water. The bare lot is the confusion the last post could not fix. The model says built-up at 80% with bare ground second. Blue alone supplies more than half of the credit and no infrared band adds more than 7 points. It is deciding between two dry mineral surfaces on a small difference in visible brightness, which is about as much as the row has to offer.
The same band is worth different amounts
Suppose you reveal the crop circle’s bands to the model one at a time and write down how far the chance of “crops” moves at each step. Reveal near infrared first and it is worth a great deal. Reveal it last, after the other five have already made the case, and it has almost nothing left to add. Across the possible orders, near infrared at that pixel is worth anything from nothing to 85 points. Red runs from minus 51 to plus 28. None of those numbers is wrong. They answer different questions.
Six bands can arrive in 720 orders. In 1953 Lloyd Shapley, working on how to split the winnings of a coalition fairly among its members, proposed the rule that is now standard here: give each player their contribution averaged over every order in which the coalition could have formed. It is the only rule under which the shares add up to the total, players who contribute identically are paid identically, and a player who adds nothing gets nothing. The bars in the first figure are Shapley values.
With six inputs the average can be taken exactly, because there are only 64 subsets of six bands to evaluate. Real models have hundreds of inputs and the tools that explain them have to sample. That is the one luxury of a model this small.
This is the first thing I now keep in mind about any attribution chart. A bar that says “near infrared: 36 points” is the middle of a spread that wide, and the chart does not show the spread. The bar is a convention for sharing out credit that was earned jointly. It is a good convention. It is still a convention.
Why blue, and not red
Back to the crop circle. Across this scene, blue and red reflectance have a correlation of 0.95, and blue and green of 0.98. A surface that is dark in one visible band is nearly always dark in the other two. As far as the model is concerned, the three visible bands are close to one column measured three times.
Training had no reason to prefer one copy over another. Some mixture of the three had to carry “this pixel is dark in visible light”, and which mixture it settled on depended on where the weights happened to start. If that is right, then training the same network again should move the credit around without changing the map much. So I trained it again. Same pixels, same labels, same settings, and a different random seed.
The second network scores 75.3% on the held-out blocks and gives the same answer as the first on 94% of pixels. By any measure I would normally apply, they are the same model. On the crop circle the first credits blue with 31 points and red with minus 4. The second credits blue with 16 and red with plus 11.
Add the three visible bands together and the disagreement mostly goes: 28 points from the first network, 25 from the second. They agree that visible light as a whole was worth a little over 25 points. They disagree about which visible band to thank.
It does not always tidy up that well. On the river the two networks split even the groups differently, 34 points for visible against 16, because in this scene the visible and shortwave bands are themselves correlated, at between 0.64 and 0.86 depending on the pair. Water is dark in all six bands, so nearly any of them can make the case. The dry field is the opposite. Both networks hand the first shortwave band most of the available credit, 47 points and 56, because nothing else in the row can stand in for it there.
That gives a usable rule. A credit is firm when no other input could have done the same job, and soft when one could. The chart does not tell you which kind you are looking at.
What the replacement costs: when I hide the crop circle’s red by borrowing red from a pixel of river, the model is asked about a surface with a crop’s infrared and water’s red. No such surface exists in the scene, and the network was never trained near it. Part of every credit on this page is the model’s behaviour on spectra it has never seen. The alternative is to borrow only from pixels that are plausible given the bands already shown, which fixes that problem and makes the credit depend on how you modelled plausibility. References 4 to 6 argue both sides.
The whole scene at once
One pixel at a time is a slow way to learn what a model does, so the last figure runs the same calculation over all 345,600 of them. The network’s own map is computed in your browser when the figure loads, which takes a fraction of a second. The credit maps are a different matter, at 2.8 billion runs of the network, so those were computed once by the same code this page uses and are shipped as images.
Start with “What led”. The expected leader is near infrared, the band that vegetation mapping has leaned on for fifty years. It leads on 12% of pixels. The visible bands lead on 58% and the shortwave bands on 30%. Near infrared wins on the irrigated circles and some of the trees, and almost nowhere else.
The reason is what the scene is made of, which is mostly not leaves. The model calls 35% of it built-up, and there the answer rests on visible brightness. It calls a quarter of it grass, which here in July is dry, and on three of those pixels in four the first shortwave band leads. Press SWIR 1 and the grassland lights up as a block. A band earns credit by separating the things that are actually in front of the model, not by being important in general.
Water is the one worth sitting with. Press NIR and the rivers are solid blue: near infrared is worth 30 points toward “water” on average, because water absorbs it almost completely. But red is worth 39 and leads on 99% of water pixels. Then press Blue, and the rivers turn red. On average the blue band argues against water, by 17 points, on pixels the model is all but certain are water.
There is probably no physical story to find for that. At the river marker the first network gives blue minus 15 points and the second gives it minus 3. It is a property of one set of weights. Train once, look only at this map, and it invites an explanation.
None of this shows in the score. Press “The model’s map” and you get an ordinary land-cover map that agrees with its labels three times in four, from a model whose reasons would not survive being trained twice.
What I take from this
Attribution earned its place on this page once, at the dry field. I had a story about why the model disagreed with its labels there, and the credit either had to land on the band that responds to moisture or the story was wrong. It landed. That is the use I trust: a specific claim about a specific prediction, checked against a mechanism I could have got wrong.
A chart like these is not a description of the world. The network did not learn that chlorophyll absorbs red. It found columns that separated the labels, and where two columns did the same work it picked between them more or less by accident. Its reasons are its own, and a second copy of it has slightly different ones.
So when someone shows me which inputs drove a model’s decision, about a parcel or a satellite or anything else, I ask three things. Compared with what: what did the model see in place of the input that was taken away? Shared out how: is this one order, or an average over all of them? And would it survive retraining, given how many of the inputs are near copies of each other? The answers are rarely on the chart. As with a validation score, the number is only as good as the procedure behind it, and the procedure is the part that tends to get left off.
The classifier looked at near infrared, mostly, and at whichever visible band it happened to pick up first.
Method
The scene, the six bands, the labels and the held-out blocks are those of the previous post, read here from the images that page ships, so the reflectances carry JPEG error and the network was trained on exactly the values your browser decodes, give or take a count. Each network is 6-16-16-6 with ReLU units and a softmax output, 486 parameters, trained on all 230,380 labelled pixels of the sixteen training blocks for 60 epochs with Adam, batch size 512 and a cosine learning-rate schedule from 0.003. Inputs are standardised by the training mean and standard deviation. The two networks differ only in the seed, which sets the initial weights and the batch order.
Credits are exact interventional Shapley values of the predicted probability. The value of a set of bands is the model’s mean output when the bands outside the set are replaced, jointly, by those of each of 128 background pixels drawn uniformly from the scene with a fixed seed. All 64 sets are evaluated, so nothing is sampled except the background. Agreement figures that appear in the figures are counted in the browser and may differ from the text in the last digit between browsers, because JPEG decoders do. The training script, the weights and the script that made the scene-wide maps are in the site’s repository.
References
- L. S. Shapley. “A value for n-person games.” In Contributions to the Theory of Games II, Annals of Mathematics Studies 28, Princeton University Press, 1953, pp. 307–317.
- E. Štrumbelj, I. Kononenko. “Explaining prediction models and individual predictions with feature contributions.” Knowledge and Information Systems, 41, 2014, pp. 647–665. Shapley values applied to a single prediction.
- S. M. Lundberg, S.-I. Lee. “A unified approach to interpreting model predictions.” Advances in Neural Information Processing Systems, 30, 2017. SHAP, the form in which most people meet this.
- D. Janzing, L. Minorics, P. Blöbaum. “Feature relevance quantification in explainable AI: A causal problem.” Proceedings of AISTATS, PMLR 108, 2020, pp. 2907–2916. The case for replacing inputs the way this page does.
- K. Aas, M. Jullum, A. Løland. “Explaining individual predictions when features are dependent: More accurate approximations to Shapley values.” Artificial Intelligence, 298, 2021, article 103502. The case against.
- I. E. Kumar, S. Venkatasubramanian, C. Scheidegger, S. Friedler. “Problems with Shapley-value-based explanations as feature importance measures.” Proceedings of ICML, PMLR 119, 2020, pp. 5491–5500.
- M. Drusch et al. “Sentinel-2: ESA’s Optical High-Resolution Mission for GMES Operational Services.” Remote Sensing of Environment, 120, 2012, pp. 25–36.
- D. Zanaga et al. ESA WorldCover 10 m 2021 v200. Zenodo, 2022. doi:10.5281/zenodo.7254221. The reference labels.