Before this: From a cube to labelled samples
From samples to a land use map
How do labelled samples become a map of land use?
- 1. The samples train the model.
- 2. The cube goes into the trained model.
- 3. The model labels every pixel: the map.
Classify one window of the Cerrado from labelled samples, with one input at a time. Choose the input below, and every step follows it.
The steps follow the book's order: time series first.
Step 01 of 7
What does the classifier learn from?
This page has a small scope: the samples of one region, one window of 256 by 256 pixels and one classifier.
The pipeline kept 4,443 labelled samples of the Cerrado, in 11 classes. Where a sample’s label comes from is told in the previous journey.
The classifier receives each sample as a row of numbers with a label. The input you chose decides which numbers.
The samples are split, class by class, at random: 3,555 to train the classifier and 888 held back. The classifier does not see the held-back samples while it learns.
One window of 256 × 256 pixels, one classifier.
Step 02 of 7
What happens while a network learns?
Before the recorded run, a small network trains here, in your browser. Press Start: in each epoch it makes one pass over the 3,555 training samples, then labels every pixel of the window.
Each colour is one of the 11 classes. After each epoch the map is repainted with the class the network now gives each pixel.
The curve is the loss on the training samples after each epoch: how far the network’s guesses are from their labels. It belongs to this sketch alone; the next step shows the run of sits.
Loading classification-series-live-window.bin (2.4 MB).
Not trained yet
Step 03 of 7
How does sits train the network?
The book trains a multilayer perceptron on its labelled samples with sits_train().
The book's code
mlp_model <- sits_train(
samples = samples_matogrosso_mod13q1,
ml_method = sits_mlp(
optimizer = torch::optim_adamw,
layers = c(512, 512, 512),
dropout_rates = c(0.40, 0.30, 0.20),
epochs = 80,
batch_size = 64,
verbose = FALSE,
validation_split = 0.2)
)Where the sits book writes this call: cl_machinelearning.qmd, lines 477–487
sits_train() fits a multilayer perceptron to the 3,555 training samples. It was run once for the input you chose, with a fixed seed.
Each epoch is one pass over the training samples. The loss measures how far the network’s guesses are from the labels, and in the recorded run the curve shows it falling as the network learns.
A part of the training samples is kept aside to validate. Training stops early when the loss on that part stops improving.
Loading classification-series.json (4 kB).
Step 04 of 7
How many held-back samples does it label correctly?
The trained network labels the 888 samples held back. Their labels are known, so each answer can be checked.
Overall accuracy is the share of them that received their own label.
Per class, the producer’s accuracy asks what share of the samples of a class were found. The user’s accuracy asks what share of the samples given a class really belong to it.
The split is random within each class, not by place. A held-back sample may lie close to a training sample, so this accuracy says little about new regions.
Loading classification-series.json (4 kB).
Step 05 of 7
How likely is each class, pixel by pixel?
Once trained, the network is applied to the whole window. For each pixel, sits_classify() gives the probability of each class. The map shows one class: the darker a pixel, the higher its probability of that class.
Choose another class to see its probabilities over the same window.
Select a pixel of the window to see its probability for every class as a bar.
The values of a pixel add up to about 1, as probabilities do. The file keeps each one rounded to one of 256 steps, so the bars of a pixel add up to about 1, not exactly.
Loading classification-series-probs.bin (721 kB).
Step 06 of 7
What does smoothing change?
sits_smooth() applies Bayesian smoothing to the probabilities, using the neighbourhood of each pixel. The map shows the smoothed probability of one class, on the same scale as before. The pipeline kept the defaults of sits_smooth().
Choose another class to see its smoothed probabilities over the window.
A pixel is labelled with the class of highest probability. The pixels marked on the map are those whose label differs between the map made from the raw probabilities and the map made from the smoothed ones.
Loading classification-series-smooth.bin (721 kB).
Step 07 of 7
What does the land use map look like?
After smoothing, every pixel keeps the class of highest probability. The map paints each pixel in the colour of its class, for the input you chose.
The legend lists the classes with the share of the labelled pixels that each one holds, counted from the map you see. The shares add up to 100 %.
Loading classification-series-map.bin (66 kB).
Try it: The land use map on the ground, from the time series