Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2021 Jul 31;21(1):158.
doi: 10.1186/s12874-021-01347-1.

Machine learning in medicine: a practical introduction to natural language processing

Affiliations

Machine learning in medicine: a practical introduction to natural language processing

Conrad J Harrison et al. BMC Med Res Methodol. .

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.

PubMed Disclaimer

Conflict of interest statement

The authors have no competing interests to declare in relation to this work.

Figures

Fig. 1
Fig. 1
Creating a document term matrix from the data
Fig. 2
Fig. 2
A part of the document term matrix
Fig. 3
Fig. 3
Latent Dirichlet allocation can be performed with a short passage of code
Fig. 4
Fig. 4
Splitting data into training and test sets

Similar articles

Cited by

References

    1. Lee CH, Yoon HJ. Medical big data: promise and challenges. Kidney Res Clin Pract. 2017 doi: 10.23876/j.krcp.2017.36.1.3. - DOI - PMC - PubMed
    1. Sidey-Gibbons JAM, Sidey-Gibbons CJ. Machine learning in medicine: a practical introduction. BMC Med Res Methodol. 2019 doi: 10.1186/s12874-019-0681-4. - DOI - PMC - PubMed
    1. Esteva A, Kuprel B, Novoa RA, et al. Dermatologist-level classification of skin cancer with deep neural networks. Nature. 2017 doi: 10.1038/nature21056. - DOI - PMC - PubMed
    1. Nadkarni PM, Ohno-Machado L, Chapman WW. Natural language processing: an introduction. J Am Med Informatics Assoc. 2011 doi: 10.1136/amiajnl-2011-000464. - DOI - PMC - PubMed
    1. Gravesteijn BY, Nieboer D, Ercole A, et al. Machine learning algorithms performed no better than regression models for prognostication in traumatic brain injury. J Clin Epidemiol. 2020 doi: 10.1016/j.jclinepi.2020.03.005. - DOI - PubMed

Publication types

LinkOut - more resources