Development and Validation of Machine Models Using Natural Language Processing to Classify Substances Involved in Overdose Deaths

JAMA Netw Open. 2022 Aug 1;5(8):e2225593. doi: 10.1001/jamanetworkopen.2022.25593.


Importance: Overdose is one of the leading causes of death in the US; however, surveillance data lag considerably from medical examiner determination of the death to reporting in national surveillance reports.

Objective: To automate the classification of deaths related to substances in medical examiner data using natural language processing (NLP) and machine learning (ML).

Design, setting, and participants: Diagnostic study comparing different natural language processing and machine learning algorithms to identify substances related to overdose in 10 health jurisdictions in the US from January 1, 2020, to December 31, 2020. Unstructured text from 35 433 medical examiner and coroners' death records was examined.

Exposures: Text from each case was manually classified to a substance that was related to the death. Three feature representation methods were used and compared: text frequency-inverse document frequency (TF-IDF), global vectors for word representations (GloVe), and concept unique identifier (CUI) embeddings. Several ML algorithms were trained and best models were selected based on F-scores. The best models were tested on a hold-out test set and results were reported with 95% CIs.

Main outcomes and measures: Text data from death certificates were classified as any opioid, fentanyl, alcohol, cocaine, methamphetamine, heroin, prescription opioid, and an aggregate of other substances. Diagnostic metrics and 95% CIs were calculated for each combination of feature extraction method and machine learning classifier.

Results: Of 35 433 death records analyzed (decedent median age, 58 years [IQR, 41-72 years]; 24 449 [69%] were male), the most common substances related to deaths included any opioid (5739 [16%]), fentanyl (4758 [13%]), alcohol (2866 [8%]), cocaine (2247 [6%]), methamphetamine (1876 [5%]), heroin (1613 [5%]), prescription opioids (1197 [3%]), and any benzodiazepine (1076 [3%]). The CUI embeddings had similar or better diagnostic metrics compared with word embeddings and TF-IDF for all substances except alcohol. ML classifiers had perfect or near perfect performance in classifying deaths related to any opioids, heroin, fentanyl, prescription opioids, methamphetamine, cocaine, and alcohol. Classification of benzodiazepines was suboptimal using all 3 feature extraction methods.

Conclusions and relevance: In this diagnostic study, NLP/ML algorithms demonstrated excellent diagnostic performance at classifying substances related to overdoses. These algorithms should be integrated into workflows to decrease the lag time in reporting overdose surveillance data.

Publication types

  • Research Support, N.I.H., Extramural

MeSH terms

  • Analgesics, Opioid
  • Benzodiazepines
  • Cocaine*
  • Drug Overdose* / epidemiology
  • Female
  • Fentanyl
  • Heroin
  • Humans
  • Male
  • Methamphetamine*
  • Middle Aged
  • Natural Language Processing


  • Analgesics, Opioid
  • Benzodiazepines
  • Methamphetamine
  • Heroin
  • Cocaine
  • Fentanyl