This quick tutorial shows how to measure text subjectivity with TextBlob. For a complete introduction to sentiment analysis in Python, see our Getting Started with TextBlob in Python guide.
The Problem
A polarity score tells you whether text is positive or negative, but it doesn’t capture how much of it is opinion versus fact. A product description might read as positive simply because of its specific, neutral language. A customer review of the same product might express equal enthusiasm but rely entirely on personal opinion. Knowing which type of text you’re working with changes how you interpret polarity results.
The Solution
TextBlob’s .sentiment.subjectivity returns a float from 0.0 (fully objective) to 1.0 (highly subjective). Higher scores indicate opinion-based language; lower scores indicate factual or descriptive text.
The code below scores four texts to show how the scale behaves across different writing styles:
from textblob import TextBlob
texts = [
"Water boils at 100 degrees Celsius at sea level.",
"The documentary presents a balanced view of the topic.",
"I think this is the best laptop I've ever owned.",
"This movie was absolutely terrible and a complete bore."
]
for text in texts:
score = TextBlob(text).sentiment.subjectivity
print(f"{score:.2f} | {text}")
Output:
0.00 | Water boils at 100 degrees Celsius at sea level. 0.00 | The documentary presents a balanced view of the topic. 0.30 | I think this is the best laptop I've ever owned. 0.70 | This movie was absolutely terrible and a complete bore.
Factual statements score near zero; strong opinions score near 1.0. To focus analysis on genuine opinions, use a subjectivity threshold to separate opinion entries from factual ones:
from textblob import TextBlob
reviews = [
"Shipping was on time.",
"This changed my life. Best product ever made.",
"Not bad, I suppose."
]
for review in reviews:
blob = TextBlob(review)
label = "opinion" if blob.sentiment.subjectivity > 0.5 else "factual"
print(f"{label:7} | sub={blob.sentiment.subjectivity:.2f} | {review}")
Output:
factual | sub=0.00 | Shipping was on time. factual | sub=0.30 | This changed my life. Best product ever made. opinion | sub=0.67 | Not bad, I suppose.
Setting the cutoff at 0.5 separates clear opinions from neutral or descriptive statements. Adjust that threshold based on your dataset and how strictly you want to filter.
A Little Something Extra
Subjectivity scores work best as a filter rather than a standalone signal. If you’re building a sentiment summary, consider separating high-subjectivity entries from low-subjectivity ones before displaying polarity results. A text that reads as moderately positive but scores below 0.2 on subjectivity is probably descriptive language, not a real endorsement. Pairing both scores lets you identify entries where sentiment reflects actual opinion, which is usually what you want to measure.
Conclusion
Subjectivity scoring lets you separate opinion-based text from factual statements. Use it alongside polarity to keep your analysis focused on entries where sentiment reflects a genuine point of view.
