Telling what a meerkat is doing from a motion sensor

A small motion sensor on a collar can tell us whether a wild meerkat is resting, keeping watch, looking for food or running. Our method does this with simple rules based on how the body moves.
By

Pritish Chakravarty

Posted

June 11, 2020

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.

A researcher in a red jacket stands on a fallen log in the Kalahari, filming a meerkat that wears a small collar and stands upright beside him.

Ground-truthing. The acceleration data stream (recorded using the animal-borne data logger, bottom-left) is synchronised with simultaneously recorded video (near top right). Photo credit: Kamiar Aminian.

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.

Diagram of a running meerkat with three arrows for the sensor's three directions, the three wavy signal lines they record, and the three measures calculated from them.

Feature engineering. Three biomechanically meaningful features were engineered from acceleration data – one each to characterise posture, movement intensity, and periodicity.

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.

Two grids of blue and orange squares standing for data used to train and to test the model. In the left grid, one whole row is orange; in the right grid, the last columns of every row are orange.

Model validation. Leave-one-individual-out cross-validation tests how well the model performs on data from an individual it has not seen. Other approaches, such as a train-test split (hold-out), mix data from different individuals, and so cannot tell how well the model works on new individuals.

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.