What is sentiment analysis?
The AI Glossary
In our classes, we often pause to explain the ideas behind AI and the language used to describe it. These posts grew out of those conversations. They’re for anyone who would like to understand AI better, with no technical background assumed.
Sentiment analysis uses software to identify an attitude expressed in language. A common task classifies a passage as positive, negative or neutral. More detailed systems may identify the subject of the opinion—for example, whether a patient liked the care but disliked the booking process.
The task is about expressed language, not direct access to a person’s feelings. Someone may describe a frustrating experience politely, use sarcasm or quote another person’s opinion. A system that counts positive and negative words can easily miss those differences.
Some methods use dictionaries of words associated with sentiment. Others learn from labeled examples or ask a language model to classify a passage. A label is the answer used to teach or evaluate the system. Those labels reflect the definitions and judgments of whoever created the task, so “negative” needs a clear meaning.
A whole-message label can hide useful information. “The nurse was excellent, but I could not get through on the phone” contains praise and criticism. Aspect-based sentiment analysis separates attitudes toward particular parts of an experience. That may be more useful for service improvement than assigning the entire message a score.
Performance depends on language, context and the examples used in development. Medical language creates familiar traps: a “positive” result may be worrying, while a “negative” result may be reassuring. Differences in dialect and communication style can also affect interpretation. A model trained on product reviews should not be assumed to work equally well on patient messages.
A clinic could use sentiment analysis to help identify recurring concerns in free-text feedback, then have staff examine the relevant messages and underlying process. It should not treat a negative label as a diagnosis of depression or as evidence that a patient is difficult. Nor should an automated sentiment score determine who receives attention without understanding its errors. The useful question is what people are saying about the service and what the organization can learn from it.
Sources: Hugging Face — Text Classification
To learn more, take a look at the AI in Health Care Certificate of Specialization from the Advanced Learning Academy at Harvard T.H. Chan School of Public Health. You can take an individual course or work toward the full certificate.
AI is a fast-moving field. This explanation reflects our class discussions and related material at the time of writing. Terminology, capabilities and tools may change.
For suggested additions or corrections, please email me at tpanch@hsph.harvard.edu.
Dr. Trishan Panch
Program Director, AI in Health Care
Harvard T.H. Chan School of Public Health — Advanced Learning Academy
Lead with AI in Health Care
The AI Pragmatist is a monthly newsletter from ALA faculty, with new explainers & essays from the Advanced Learning Academy