NB 24 Aug
NB 24 Aug
unbelievably disappointing
Full of zany characters and richly applied satire, and
some great plot twists
this is the greatest screwball comedy ever filmed
It was pathetic. The worst part about it was the
boxing scenes.
4
Classification
Assigning subject categories, topics, or genres
Spam detection
Authorship identification (who wrote this?)
Language Identification (is this Portuguese?)
Sentiment analysis
…
Text Classification: definition
Input:
◦ a instance d
◦ a fixed set of classes C = {c1, c2,…, cJ}
8
Classification Methods:
Supervised Machine Learning
MAP is “maximum a
posteriori” = most
likely class
Bayes Rule
Dropping the
denominator
Naive Bayes Classifier (II)
"Likelihood" "Prior"
instance d
represented as
features x1..xn
Naïve Bayes Classifier (IV)
available.
Multinomial Naive Bayes Independence
Assumptions
This:
Notes:
1) Taking log doesn't change the ranking of classes!
The class with highest probability also has highest log probability!
2) It's a linear model:
Just a max of a sum of weights: a linear function of the inputs
So naive bayes is a linear classifier
Text
Classificati The Naive Bayes Classifier
on and
Naive
Bayes
Text
Classificati
on and Naive Bayes: Learning
Naïve
Bayes
Sec.13.3
𝑁𝑐
^ (𝑐 )=
𝑃 𝑗
𝑗
𝑁 𝑡𝑜𝑡𝑎𝑙
Parameter estimation
36
Binary multinominal naive Bayes
Binary multinominal naive Bayes
Binary multinominal naive Bayes
Binary multinominal naive Bayes
Riloff and Wiebe (2003). Learning extraction patterns for subjective expressions. EMNLP-2003.
Naïve Bayes:
Relationship to
Language Modeling
Dan Jurafsky
c=China
54
Dan Jurafsky
Naïve Bayes:
Relationship to
Language Modeling
Text
Classificati Precision, Recall, and F1
on and
Naive
Bayes
Evaluating Classifiers: How well does our classifier work?
Let's first address binary classifiers:
• Is this email spam?
spam (+) or not spam (-)
• Is this post about Delicious Pie Company?
about Del. Pie Co (+) or not about Del. Pie Co(-)
Stupid classifier: Just say no: every tweet is "not about pie"
• 100 tweets talk about pie, 999,900 tweets don't
• Accuracy = 999,900/1,000,000 = 99.99%
But the Recall and Precision for this classifier are terrible:
A combined measure: F1
We can define precision and recall for multiple classes like this 3-way
email task:
How to combine P/R values for different classes:
Microaveraging vs Macroaveraging
Text
Classificati Precision, Recall, and F1
on and
Naive
Bayes
Text
Classificati Avoiding Harms in Classification
on and
Naive
Bayes
Harms of classification
Classifiers, like any NLP algorithm, can cause harms
This is true for any classifier, whether Naive Bayes or
other algorithms
Representational Harms
• Harms caused by a system that demeans a social group
• Such as by perpetuating negative stereotypes about them.
• Kiritchenko and Mohammad 2018 study
• Examined 200 sentiment analysis systems on pairs of sentences
• Identical except for names:
• common African American (Shaniqua) or European American (Stephanie).
• Like "I talked to Shaniqua yesterday" vs "I talked to Stephanie yesterday"
• Result: systems assigned lower sentiment and more negative
emotion to sentences with African American names
• Downstream harm:
• Perpetuates stereotypes about African Americans
• African Americans treated differently by NLP tools like sentiment (widely
used in marketing research, mental health studies, etc.)
Harms of Censorship
• Toxicity detection is the text classification task of detecting hate speech,
abuse, harassment, or other kinds of toxic language.
• Widely used in online content moderation
• Toxicity classifiers incorrectly flag non-toxic sentences that simply mention
minority identities (like the words "blind" or "gay")
• women (Park et al., 2018),
• disabled people (Hutchinson et al., 2020)
• gay people (Dixon et al., 2018; Oliva et al., 2021)
• Downstream harms:
• Censorship of speech by disabled people and other groups
• Speech by these groups becomes less visible online
• Writers might be nudged by these algorithms to avoid these words
Performance Disparities
1. Text classifiers perform worse on many languages
of the world due to lack of data or labels
2. Text classifiers perform worse on varieties of
even high-resource languages like English
• Example task: language identification, a first step in
NLP pipeline ("Is this post in English or not?")
• English language detection performance worse for
writers who are African American (Blodgett and
O'Connor 2017) or from India (Jurgens et al., 2017)
Harms in text classification
• Causes:
• Issues in the data; NLP systems amplify biases in training data
• Problems in the labels
• Problems in the algorithms (like what the model is trained to
optimize)
• Prevalence: The same problems occur throughout NLP
(including large language models)
• Solutions: There are no general mitigations or solutions
• But harm mitigation is an active area of research
• And there are standard benchmarks and tools that we can use for
measuring some of the harms
Text
Classificati Avoiding Harms in Classification
on and
Naive
Bayes