A colour-sorting task
Olive oil varies in colour from pale gold to deep green, depending on the olive variety, ripeness and processing. Imagine a model trained to sort photographs of olive oil into colour groups, perhaps to help catalogue products. It looks at each image and predicts the oil's colour.
Glass changes the light
Olive oil is often sold in dark green or brown glass bottles, which protect it from light that can spoil it. But tinted glass also changes the colour of light passing through it. Before the camera records anything, the bottle has already altered what the oil looks like. A pale oil in green glass may appear dark green in a photograph.
A hidden shortcut
If the training photographs mostly show green oils in green bottles and golden oils in clear bottles, a model might learn to recognise the bottle colour rather than the oil. It could appear accurate, while actually detecting the packaging. This kind of shortcut is a common problem in machine learning.
A matched pair
To test this, take the same oil and place it in a clear bottle and a tinted bottle. Photograph both under the same lighting, with the same camera and background. The oil is identical, so a model that truly reads the oil's colour should give the same answer for both images.
Interpreting the result
If the model's prediction changes when only the bottle changes, it is responding to the packaging. If the prediction stays the same, the model is more likely reading the oil itself. Repeating the test with several oils and bottle colours gives a clearer picture.
Controlling the light
Lighting matters as much as glass. Warm or cool lamps, daylight and shadows all change colours in photographs. A fair test keeps the lighting fixed, or includes a neutral grey or white reference card in each image, so colours can be compared consistently.
What a photograph cannot show
A photograph can show the visible colour of oil, but it cannot establish its quality grade. Grades such as extra virgin depend on chemical tests, such as acidity, and on sensory assessment by trained tasters. Colour alone is not a reliable sign of quality, so the model's task should be limited to visible colour.
Defining the target
It is important to be clear about what the model is predicting. Is it the colour of the oil, the colour of the bottle, or the apparent colour of the whole image? Defining the target precisely helps design fair tests and avoids claiming more than the model can do.
Improving the model
If the model is fooled by tinted glass, it can be trained with more varied examples, including the same oils in different containers, so it learns that bottle colour is not the target. Alternatively, oil samples could be photographed in a standard clear container under fixed light.
Testing under real conditions
The NIST AI Risk Management Framework encourages testing AI systems in conditions that match their real use. If the model will see oil in many kinds of bottle, the test set should include those bottles, so its performance is measured honestly.
Why bottles are tinted
Light can trigger chemical changes in olive oil that spoil its flavour, so producers often use dark glass or tins. Clear bottles let shoppers see the oil but offer less protection. Storing oil in a cool, dark place helps keep it fresh, whatever the container.
Many origins
Olive oil is produced around the Mediterranean and beyond.
Try the arithmetic
If a model gives the same colour for 18 of 20 oils in both clear and tinted bottles, its predictions are consistent for 90 per cent of the matched pairs.
The idea to take away
Tinted glass changes how oil looks before a photograph is taken. Testing matched pairs of the same oil in different containers shows whether a model's predictions follow the oil or the packaging. A photograph can show colour, but not the oil's grade.
Sources & further reading
Figures in the example are illustrative. Photograph: Vinegar & Oil.JPG by haitham alfalah, CC0, via Wikimedia Commons; cropped and resized. Reference organisations do not endorse this website.

