Machine learning in medicine: a practical introduction to natural language processing
- PMID: 34332525
- PMCID: PMC8325804
- DOI: 10.1186/s12874-021-01347-1
Machine learning in medicine: a practical introduction to natural language processing
Abstract
Background: Unstructured text, including medical records, patient feedback, and social media comments, can be a rich source of data for clinical research. Natural language processing (NLP) describes a set of techniques used to convert passages of written text into interpretable datasets that can be analysed by statistical and machine learning (ML) models. The purpose of this paper is to provide a practical introduction to contemporary techniques for the analysis of text-data, using freely-available software.
Methods: We performed three NLP experiments using publicly-available data obtained from medicine review websites. First, we conducted lexicon-based sentiment analysis on open-text patient reviews of four drugs: Levothyroxine, Viagra, Oseltamivir and Apixaban. Next, we used unsupervised ML (latent Dirichlet allocation, LDA) to identify similar drugs in the dataset, based solely on their reviews. Finally, we developed three supervised ML algorithms to predict whether a drug review was associated with a positive or negative rating. These algorithms were: a regularised logistic regression, a support vector machine (SVM), and an artificial neural network (ANN). We compared the performance of these algorithms in terms of classification accuracy, area under the receiver operating characteristic curve (AUC), sensitivity and specificity.
Results: Levothyroxine and Viagra were reviewed with a higher proportion of positive sentiments than Oseltamivir and Apixaban. One of the three LDA clusters clearly represented drugs used to treat mental health problems. A common theme suggested by this cluster was drugs taking weeks or months to work. Another cluster clearly represented drugs used as contraceptives. Supervised machine learning algorithms predicted positive or negative drug ratings with classification accuracies ranging from 0.664, 95% CI [0.608, 0.716] for the regularised regression to 0.720, 95% CI [0.664,0.776] for the SVM.
Conclusions: In this paper, we present a conceptual overview of common techniques used to analyse large volumes of text, and provide reproducible code that can be readily applied to other research studies using open-source software.
© 2021. The Author(s).
Conflict of interest statement
The authors have no competing interests to declare in relation to this work.
Figures
Similar articles
-
Machine learning in medicine: a practical introduction.BMC Med Res Methodol. 2019 Mar 19;19(1):64. doi: 10.1186/s12874-019-0681-4. BMC Med Res Methodol. 2019. PMID: 30890124 Free PMC article.
-
Digital Epidemiology of Prescription Drug References on X (Formerly Twitter): Neural Network Topic Modeling and Sentiment Analysis.J Med Internet Res. 2024 Aug 23;26:e57885. doi: 10.2196/57885. J Med Internet Res. 2024. PMID: 39178036 Free PMC article.
-
Risk prediction using natural language processing of electronic mental health records in an inpatient forensic psychiatry setting.J Biomed Inform. 2018 Oct;86:49-58. doi: 10.1016/j.jbi.2018.08.007. Epub 2018 Aug 14. J Biomed Inform. 2018. PMID: 30118855
-
Applying natural language processing and machine learning techniques to patient experience feedback: a systematic review.BMJ Health Care Inform. 2021 Mar;28(1):e100262. doi: 10.1136/bmjhci-2020-100262. BMJ Health Care Inform. 2021. PMID: 33653690 Free PMC article.
-
Machine learning applications to clinical decision support in neurosurgery: an artificial intelligence augmented systematic review.Neurosurg Rev. 2020 Oct;43(5):1235-1253. doi: 10.1007/s10143-019-01163-8. Epub 2019 Aug 17. Neurosurg Rev. 2020. PMID: 31422572
Cited by
-
Urban resilience to socioeconomic disruptions during the COVID-19 pandemic: Evidence from China.Int J Disaster Risk Reduct. 2023 Jun 1;91:103670. doi: 10.1016/j.ijdrr.2023.103670. Epub 2023 Apr 5. Int J Disaster Risk Reduct. 2023. PMID: 37041883 Free PMC article.
-
Artificial Intelligence for Clinical Management of Male Infertility, a Scoping Review.Curr Urol Rep. 2024 Nov 9;26(1):17. doi: 10.1007/s11934-024-01239-z. Curr Urol Rep. 2024. PMID: 39520645 Free PMC article.
-
Externally validated and clinically useful machine learning algorithms to support patient-related decision-making in oncology: a scoping review.BMC Med Res Methodol. 2025 Feb 21;25(1):45. doi: 10.1186/s12874-025-02463-y. BMC Med Res Methodol. 2025. PMID: 39984835 Free PMC article.
-
Leveraging Artificial Intelligence and Data Science for Integration of Social Determinants of Health in Emergency Medicine: Scoping Review.JMIR Med Inform. 2024 Oct 30;12:e57124. doi: 10.2196/57124. JMIR Med Inform. 2024. PMID: 39475815 Free PMC article.
-
A case study on generative artificial intelligence to extract the fundamental sleep parameters from polysomnography notes.J Clin Sleep Med. 2025 Jun 1;21(6):1123-1127. doi: 10.5664/jcsm.11594. J Clin Sleep Med. 2025. PMID: 40012317
References
Publication types
MeSH terms
LinkOut - more resources
Full Text Sources