Scientists have developed a new artificial intelligence tool that can predict whether someone will attempt suicide as far off as two years into the future with up to 80 per cent accuracy.

Researchers including those from Florida State University in the US accessed a massive data repository containing the electronic health records of about two million patients.

The team then combed through the electronic health records, which were anonymous, and identified more than 3,200 people who had attempted suicide.

Using machine learning to examine all of those details, the algorithms were able to 'learn' which combination of factors in the records could most accurately predict future suicide attempts.

"The machine learns the optimal combination of risk factors. What really matters is how this algorithm and these variables interact with one another as a whole," said Jessica Ribeiro of Florida State University.

"This kind of work lets us apply algorithms that can consider hundreds of data points in someone's medical record and potentially reduce them to clinically meaningful information," said Ribeiro.

The study offers a fascinating finding that machine learning – a future frontier for artificial intelligence can predict with 80-90 per cent accuracy of whether someone will attempt suicide as far off as two years into the future.

The algorithms become even more accurate as a person's suicide attempt gets closer, researchers said.

For example, the accuracy climbs to 92 per cent one week before a suicide attempt when artificial intelligence focuses on general hospital patients.

"This study provides evidence that we can predict suicide attempts accurately. We can predict them accurately over time, but we are best at predicting them closer to the event.

"We also know, based on this study, that risk factors like how they work and how important they are also change over time." Ribeiro said.

The study appears in the journal Clinical Psychological Science.