The aftershocks of a devastating earthquake can often be as horrifying as the main event. Now scientists have developed a system for predicting where such post-quake tremors could take place, and they've used an ingenious application of artificial intelligence (AI) to make this happen.

Knowing more about what's coming next can be a matter of life or death for communities reeling from a large quake. The aftershocks can often cause further injuries and fatalities, damage buildings, and complicate rescue efforts.

A team led by researchers from Harvard University has trained AI to crunch huge amounts of sensor data and apply deep learning to make more accurate predictions.

The researchers behind the new system say it's not ready to be deployed yet, but is already more reliable at pinpointing aftershocks than current prediction models.

In the years ahead, it could become a vital part of the prediction systems used by seismologists.

"There are three things you want to know about earthquakes – you want to know when they are going to occur, how big they're going to be and where they're going to be," says one of the team, Brendan Meade from Harvard University in Massachusetts.

"Prior to this work we had empirical laws for when they would occur and how big they were going to be, and now we're working the third leg, where they might occur."

The idea to use deep learning to tackle this came to Meade when he was on a sabbatical at Google – a company where AI is being deployed in many different areas of computing and science.

Machine learning is just one facet of AI, and is exactly what it sounds like: machines learning from sets of data, so they can cope with new problems that they haven't been specifically programmed to tackle.

Deep learning is a more advanced type of machine learning, applying what are called neural networks to try and mimic the thinking processes of the brain.

In simple terms it means the AI can see more possible results at once, and weigh up a more complex map of factors and considerations, sort-of like neurons in a brain would.

It's perfect for earthquakes, with so many variables to consider – from the strength of the shock to the position of the tectonic plates to the type of ground involved. Deep learning could potentially tease out patterns that human analysts could never spot.

To put this to use with aftershocks, Meade and his colleagues tapped into a database of over 131,000 pairs of earthquake and aftershock readings, taken from 199 previous earthquakes.

Having let the AI engine chew through those, they then got it to predict the activity of more than 30,000 similar pairs, suggesting the likelihood of aftershocks hitting locations based on a grid of 5 square kilometre (1.9 square mile) units.

The results were ahead of the Coulomb failure stress change model currently in use. If 1 represents perfect accuracy, and .5 represents flipping a coin, the Coulomb model scored 0.583, and the new AI system managed 0.849.

"I'm very excited for the potential for machine learning going forward with these kind of problems – it's a very important problem to go after," says one of the researchers, Phoebe DeVries from Harvard University.

"Aftershock forecasting in particular is a challenge that's well-suited to machine learning because there are so many physical phenomena that could influence aftershock behaviour and machine learning is extremely good at teasing out those relationships."

A key ingredient, the researchers say, was the addition of the von Mises yield criterion into the AI's algorithms – a calculation that can predict when materials will break under stress. Previously used in fields like metallurgy, the calculation hasn't been extensively used in modelling earthquakes before now.

There's still a way to go here – the researchers point out their current AI models are only designed to deal with one type of aftershock trigger, and simple fault lines: it's not yet a system that can be applied to any kind of quake around the world.

What's more, it's too slow right now to predict the deadly aftershocks that can happen a day or two after the first earthquake.

However, the good news is that neural networks are designed to continually get better over time, which means with more data and more learning cycles, the system should steadily improve.

"I think we've really just scratched the surface of what could be done with aftershock forecasting… and that's really exciting," says DeVries.

The research has been published in Nature.