Researchers have identified an incredibly smart method used by fruit flies to categorise odours – and it's so clever it could be applied to powering recommendation algorithms for the likes of Netflix or Spotify.

In the same way that YouTube might want to flag up videos similar to the one you've just watched, fruit flies – like many other animals – need to know which smells are similar, for finding food and avoiding poisonous substances.

The team from the University of California San Diego (UCSD) and the Salk Institute for Biological Studies in California has found that fruit flies have an especially clever way of categorising odours which lets them recognise differences with a very fine level of accuracy.

"In the natural world, you're not going to encounter exactly the same odour every time; there's going to be some noise and fluctuation," says one of the researchers, Saket Navlakha from Salk.

"But if you smell something that you've previously associated with a behaviour, you need to be able to identify that similarity and recall that behaviour."

It turns out that fruit flies are really good at this: and potentially better, in fact, than the algorithms that run behind streaming services and search engines.

Today, services like Netflix and Spotify will find similar items by stripping them down to their core components to make comparisons easier. Labels known as "hashes" or "tags" are assigned to each item so they can be quickly sorted.

You end up with buckets of items, like movies or songs from a particular genre – it's then easier to sort through ten buckets than a million songs or shows. Technically, the process is known as locality-sensitive hashing.

Fruit flies also make use of a kind of locality-sensitive hashing, but they build on top of it, according to the new study, which looked at previously collected data – instead of reducing items to fewer buckets, they create more buckets.

Inside the fruit fly's brain, 50 neurons react to the initial scent, before leading to 2,000 more neurons to give each smell a distinct ID in the brain.

fruit fly search 2Illustration of a fruit fly similarity search (Salk Institute)

Only the top 5 percent of each of those 2,000 neurons are stored, acting as the hash for each bucket, but the system is very effective at noticing similarities. The extra mapping allows for extra accuracy.

"Say you have a bunch of people clustered by their relationships, and they're bunched into a crowded room," says Navlakha. "Then take the same people and relationships, but have them spread out on a football field."

"It will be much easier to see the structure of relationships and draw boundaries between groups in the expanded space relative to the crowded space."

While this mechanism has been reported on before, the UCSD and Salk team is the first to draw the connection to computer algorithms that need to spot similarities. In a series of tests on three standard datasets commonly used by computer scientists, the fly method significantly outperformed basic locality-sensitive hashing.

Netflix, YouTube, Spotify, and the rest will have their own ideas about the best way to build a recommendation engine, but one day you might get a new movie or song suggested thanks to the humble fruit fly. The next step is testing the technique on more data.

"This is a problem that pretty much every technology company with any kind of information retrieval system has to solve, so it's been something that computer scientists have studied for years," says Navlakha.

"Pieces of this approach had been used in the past by computer scientists, but evolution put it together in a very unique way."

The research has been published in Science.

The researchers also put together a video on the study, which you can see below: