By GREGORY ZELLER //
A Stony Brook University computer professor with an AI algorithm that detects substance abuse through language has refocused the impressive prediction technology on opioids – with startling results.
Associate Computer Science Professor H. Andrew Schwartz is the senior author of a new study detailing the use of artificial intelligence to predict opioid mortalities. The work builds on Schwartz’s earlier success identifying high- and low-risk alcohol abuse via an AI application that interpreted language used in Facebook posts.
This time, Schwartz and four other authors – including lead author Matthew Matero, an SBU computer-science student, and National Institute on Drug Abuse Data Scientist Salvatore Giorgi – hope to create some desperately needed “location-specific aid for the U.S. opioid crisis,” according to the abstract of an article published last week by the peer-reviewed open-access journal Npj Digital Medicine.
Schwartz et al used a “sophisticated AI algorithm” to review social media posts from the years 2011 to 2017 and predict opioid death rates – and did so “much more accurately” than traditional prediction metrics, which include generalized statistics like community-wide death rates and regional socioeconomic factors.

H. Andrew Schwartz: Model behavior.
With the National Center for Health Statistics calculating a 350 percent increase in age-adjusted opioid-related deaths over the last two decades, the ability to predict an opioid crisis before it happens could be a frontline gamechanger – and it’s a lot more nuanced than flagging posts where people overtly reference “drugs” or “death.”
The team’s Transformer for Opioid Prediction (stylized as “TrOP”) does calculate past opioid-related mortality rates and other community-based data, but also leverages a “community-specific social media language” derived from the County Tweet Lexical Bank, a Twitter word-usage dataset collected from thousands of U.S. counties since 2011.
In this study, TrOP’s sequence modeling and other AI advances analyzed year-by-year changes in Twitter language and combined those findings with years of U.S. Centers for Disease Control and Prevention stats tracking county-by-county opioid deaths.
It then predicted opioid-related mortality rates for the study years in the study zones – and came within a statistical hair (1.15 deaths per 100,000 people) of total accuracy.
“The main result of this study was in fact a statistical evaluation of how well our AI model’s predictions lined up with what really happened,” Schwartz said this week. “And doing this without assuming any particular language used in social posts should equate to mortality.”
Focusing TrOP on opioids was even more successful than using AI-powered social-post reviews to predict excessive alcohol use. Detailed last May in the scientific journal Alcoholism Clinical & Experimental Research, Schwartz’s study of Facebook data from 3,600 adult volunteers produced a 75 percent chance of correctly flagging binge-drinkers – not as on-point as the opioid predictions, but still way better than traditional alcoholism risk assessments.

Off the chart: TrOP easily outperformed traditional opioid-death prediction models — and almost perfectly matched real-world outcomes.
Student Matero, field expert Giorgi – who’s studying for a PhD in computer science at the University of Pennsylvania – and researcher Schwartz will continue to test TrOP’s accuracy, and stand ready to update the AI model as social media language evolves.
It’s not a cure-all, according to Schwartz, who lamented “a very complex problem that certainly needs a multifaceted and evolving response.” But the alcoholism and now opioid studies suggest TrOP could be a powerful weapon in the national war against substance abuse – and particularly against the scourge of opioid overdoses.
“Community-specific predictions are just one line of attack,” Schwartz added. “What this work with TrOP provides is the potential for more accurate predictions for opioid-related deaths, which would give professionals and community leaders the ability to better prepare and target areas where there is likely to be an increase in mortality.”


