Telling what a meerkat is doing from a motion sensor
Accelerometers, ground truthing and machine learning
An accelerometer is a small motion sensor, like the one in your phone that knows when you turn it sideways. Accelerometers are sensitive to movement and the lack of it. But they are not sentient: on their own, they cannot tell us what an animal is doing. A person first has to teach the computer which movements go with which behaviour, and this needs ground truth data: real observations of the animal.
So we film the collared animal, an expert notes what it is doing second by second, and we line this up with the sensor signal. The signal is cut into short pieces (say, two seconds each), and from each piece we calculate a few numbers that summarise it. A machine learning algorithm then learns which numbers go with which behaviour, and is tested on data it has not seen yet. This works well, but the computer does not explain why it decides as it does.
Using how the body moves
Animals rest for a while, then start foraging, and then, perhaps sensing a threat, run. These behaviours differ in posture (upright when keeping watch, flat when running), in how vigorous the movement is, and in whether it repeats in a rhythm. We reasoned that three well-chosen measures, one each for posture, intensity and rhythm, should be enough to tell them apart.
We then built a tree of decisions that first separates broad groups of behaviour and then finer ones, with a simple algorithm at each step. We tried it on 10 wild meerkats in the Kalahari. The model recognised resting, vigilance (keeping watch), foraging and running, which together make up more than 95% of a meerkat’s day, with an accuracy of more than 95%.
Testing on animals the model has never seen
What we really want is a model that works on a new animal. So we trained it on all meerkats but one and tested it on the one left out, and repeated this until every meerkat had been left out once. Other ways of testing mix data from the same animals into both the learning and the test sets, which can make a model look better than it is. Ours is the first study to test a behaviour model in this stricter way on wild, free-living animals.
Why overall accuracy is not enough
Animals spend much more time on some behaviours than on others. A model can then score well overall and still be poor at spotting the rarer ones. A good model does well on each behaviour of interest, so it is worth checking each one on its own.
Benefits of biomechanically ‘aware’ learning
Our approach was on average 2.7% more accurate than the best classical machine learning approaches, and it copes better with rare behaviours. Because every step makes sense in terms of how the body moves, we can see why some behaviours get mixed up. Other studies on the same species can reuse parts of the model instead of building one from scratch every time. And in a follow-up paper in Movement Ecology, we showed that the same framework works with magnetometers (compass sensors) too.
To find out more, check out our Methods in Ecology and Evolution article, ‘A novel biomechanical approach for animal behaviour recognition using accelerometers’, by Pritish Chakravarty, Gabriele Cozzi, Arpat Ozgul and Kamiar Aminian. It is part of our meerkat dispersal project.
This article was shortlisted for the Robert May Prize 2019. Read more about the shortlisted articles on the Methods blog.


