Take a slice of cake and cut it in two. Eat one half, and let a friend scoff the other. Your blood-sugar levels will both spike, but to different degrees depending on your genes, the bacteria in your gut, what you recently ate, how recently or intensely you exercised, and more. The spikes, formally known as “postprandial glycemic responses” or PPGR, are hard to forecast since two people might react very differently to exactly the same food.

But Eran Elinav and Eran Segal from the Weizmann Institute of Science have developed a way of embracing that variability. By comprehensively monitoring the blood sugar, diets, and other traits of 800 people, they built an algorithm that can accurately predict how a person's blood-sugar levels will spike after eating any given meal.

They also used these personalized predictions to develop tailored dietary plans for keeping blood sugar in check. These plans sometimes included unconventional items like chocolate and ice-cream, and were so counter-intuitive that they baffled both the participants and dieticians involved in the study. But they seemed to work when assessed in a clinical trial, and they hint at a future when individuals will get personalized dietary recommendations, rather than hewing to universal guidelines.

Currently, the most common method for forecasting a person's PPGR is to look at the carbohydrate content of their meals. “People with type I diabetes determine how much insulin to inject based on the amount of carbs they're going to have in the meal,” says Segal. “That's the gold standard,” but carb content only weakly correlates with PPGR.

Alternatively, people could consult the glycemic index (GI), which puts a number on a food's effect on blood sugar. But the Weizmann team argues that these numbers are based on single foods, and don't reflect realistic meals with combinations of ingredients in varying amounts. “Ascribing a single PPGR to each food also assumes that the response is solely an intrinsic property of the food,” adds Segal. “But there are very striking differences between people's responses to identical meals.” Their genes, lifestyle choices, the bacteria in their guts, and even the meals they had recently eaten, all have an influence.

To account for these factors, students David Zeevi and Tal Korem subjected 800 non-diabetic volunteers to “the most comprehensive profiling we could.” Upon signing up, each participant filled out a questionnaire about their medical histories and dietary habits, and provided a stool sample so the team could analyze their gut microbes.

Then, for a week, they wore skin-mounted monitors that continuously measured their blood sugar, and used a mobile app to record exercise and sleep patterns, stressful events, and all their meals, down to the weights of every ingredient where possible. For their first bites of the day, they ate one of four standardized meals that the team provided. Beyond that, they ate their usual food.

Although people are often notoriously unreliable at documenting their meals, Segal says that his volunteers were unusually motivated. “We didn't pay them,” he says. “They joined because we explained that we'd be able to tell them which of the foods they normally eat spike their glucose levels. They came because they wanted to know and we said that if they didn't log properly, we wouldn't be able to tell them.”

The team found a huge amount of variation between the volunteers. The same food would cause huge sugar spikes in some people but tiny blips in others. The volunteers also differed substantially in the foods that triggered the sharpest spikes: Participant 445, for example, reacted strongly to bananas, while participant 644 spiked heavily post-cookies. “When people talk to their diabetic friends about foods that spike their glucose level, it's really different for everyone,” says Segal. “That's the intuition but, as far as I know, it's never been demonstrated quantitatively on this scale.”

Zeevi and Korem showed that these personal differences were influenced by familiar factors like age and body mass index, and also less familiar ones like gut microbes. They found several groups of bacteria, and families of bacterial genes, that were linked to stronger PPGRs.

The team developed an algorithm that used all of these individual characteristics—some 137 factors in total—to predict a person's blood-sugar responses to different foods. Unlike carbohydrate counting or the glycemic index, this algorithm doesn't just look at the nutrient content of a meal, but also the traits of the person eating it.

It was remarkably accurate. When the team tested it on a fresh set of 100 volunteers, it predicted sugar spikes that matched the volunteers' actual data with a correlation of 0.7 (where 1 would be perfect). That's good: Even if the same person eats the same meal on two different days, the correlation between the two sugar spikes will be 0.77 at most. That sets a ceiling for predictability, one that the team's algorithm came very close to hitting. It certainly outperformed the crude technique of counting carbs or calories; when Zeevi and Korem tried doing that, they got correlations of just 0.38 and 0.33.

The algorithm could even provide people with effective, tailored dietary advice. The team recruited 26 new volunteers and randomly split them into two groups. Everyone was given two week-long diets—a “good” one designed to minimize their PPGRs, and a “bad” one designed to trigger big spikes. But one group received plans that were designed by a pair of experts, while the other stuck to diets fashioned by the algorithm.

Many of the diets created by the algorithm were deeply unorthodox. “It wasn't just salad every day,” says Segal. “Some people got alcohol, chocolate, and ice-cream, in moderation. These are items that you'd typically never find on a dietician's recommendations.” Some plans were so counter-intuitive that neither dieticians nor volunteers could tell whether they were meant to represent the good diet or the bad one. And yet, they effectively controlled blood-sugar levels for those particular volunteers.

For both groups of volunteers, “the differences were dramatic,” says Segal. “On the bad diets, blood glucose really reached abnormal level, but on the good diets, they normalized to healthy ranges.” And even though each participant ate different personalized meals, their gut microbes changed in consistent and perhaps beneficial ways. For example, several bacterial groups that had been associated with type 2 diabetes went down.

The algorithm even performed as well as the two experts, if not slightly better. And Segal says that it's ultimately more versatile. The dieticians based their plans on each participant's PPGRs to the meals they are in the previous week. The algorithm did that too, but it can also predict responses to any meal. “It's not constrained to recommending people meals that have already been measured,” says Segal. “You could recommend any meal.”

Jennie Brand-Miller, a nutritionist at the University of Sydney and the director of the Glycemic Index Foundation, calls the study is a “game-changer” for showing a connection between PPGRs and gut bacteria, and for looking at these responses in healthy people without diabetes. “This drives home the medical relevance of high glucose levels within the so-called normal range,” she says.

But she adds that the researchers “draw a long bow” in dismissing the glycemic index and other metrics for predicting blood-sugar responses, which are better than the team gives them credit for. Similarly, David Jenkins from the University of Toronto adds that the team didn't directly compare their algorithm to indices like GI. “It's not a helpful paper,” he says.

But Segal thinks that the algorithm can only get better. His team is planning to improve it by collecting more detailed information about the volunteers' physical activity, the bacterial strains in the gut, and even their genetics. They are also running a longer study to see if the personalized diets concocted by their algorithm can, over the course of a year, improve the health of prediabetic people at risk of developing type 2 diabetes.

They're certainly not short of volunteers. The first wave of participants were so intrigued by their results that they urged their friends and family to sign up. Segal's team ended up recruiting their 900 participants almost entirely through word of mouth, without any payment or marketing. “We have more than 4000 on the waiting list to take part in the next study,” he says.