Identifying Spurious Correlations for Robust Text Classification (2020)

Abstract: The predictions of text classifiers are often driven by spurious correlations – e.g., the term “Spielberg” correlates with positively reviewed movies, even though the term itself does not semantically convey a positive sentiment. In this paper, we propose a method to distinguish spurious and genuine correlations in text classification. We treat this as a supervised classification problem, using features derived from treatment effect estimators to distinguish spurious correlations from “genuine” ones. Due to the generic nature of these features and their small dimensionality, we find that the approach works well even with limited training examples, and that it is possible to transport the word classifier to new domains. Experiments on four datasets (sentiment classification and toxicity detection) suggest that using this approach to inform feature selection also leads to more robust classification, as measured by improved worst-case accuracy on the samples affected by spurious correlations.

## introduction text classifiers often rely on spurious correlations. for example, consider sentiment classification of movie reviews. the term spielberg may be correlated with the positive class because many of director steven spielberg's movies have positive reviews. however, the term itself does not indicate a positive review. in other words, the term spielberg does not cause the review to be positive. similarly, consider the problem of toxicity classification of online comments. terms indicative of certain ethnic groups may be associated with the toxic class because those groups are often victims of harassment, not because those terms are toxic themselves. oftentimes, such spurious correlations do not harm prediction accuracy because the same correlations exist in both training and testing data (under the common assumption of i.i.d. sampling). however, they can still be problematic for several reasons. for example, under dataset shift @xcite , the testing distribution differs from the training distribution. e.g., if steven spielberg makes a new, bad movie, the sentiment classifier may incorrectly classify the reviews as positive because they contain the term spielberg. additionally, if the spurious correlations indicate demographic attributes, then the classifier may suffer from issues of algorithmic fairness @xcite . for example, the toxicity classifier may unfairly over-predict the toxic class for comments discussing certain demographic groups. finally, in settings where classifiers must explain their decisions to humans, such spurious correlations can reduce trust in autonomous systems @xcite . in this paper, we propose a method to distinguish spurious correlations, like spielberg, from genuine correlations, like wonderful, which more reliably indicate the class label. our approach is to treat this as a separate classification task, using features drawn from treatment effect estimation approaches that isolate the impact each word has on the class label, while controlling for the context in which it appears. we conduct classification experiments with four datasets and two tasks (sentiment classification and toxicity detection), focusing on the problem of short text classification (i.e., single sentences or tweets). we find that with a small number of labeled word examples (200-300), we can fit a classifier to distinguish spurious and genuine correlations with moderate to high accuracy (.66-.82 area under the roc curve), even when tested on terms most strongly correlated with the class label. in addition, due to the generic nature of the features, we can train a word classifier on one domain and transfer it to another domain without much loss in accuracy. finally, we apply the word classifier to inform feature selection for the original classification task (e.g., sentiment classification and toxicity detection). following recent work on distributionally robust classification @xcite , we measure worst-case accuracy by considering samples of data most affected by spurious correlations. we find that removing terms in the order of their predicted probability of being spurious correlations can result in more robust classification with respect to this worst-case accuracy. ## problem and motivation we consider binary classification of short documents, e.g., sentences or tweets. each sentence is a sequence of words @xmath0. . . w k with a corresponding binary label @xmath1, 1}. to classify a sentence s, it is first transformed into a feature vector x via a feature function g : @xmath2. then, the feature vector is assigned a label by a classification function f : (x; θ) → {-1, 1}, with model parameters θ. parameters θ are typically estimated from a set of i. to illustrate the problem addressed in this paper, we will first consider the simple approach of a bag-of-words logistic regression classifier. in this setting, the feature function g(s) simply maps a document to a word count vector @xmath3. . . x v }, for vocabulary size v , and the classification function is the logistic function f (x; θ) = 1 1+e -x,θ . after estimating parameters θ on labeled data d, we can then examine the coefficients corresponding to each word in the vocabulary to see which words are most important in the model. in figure 1 , we show eight words with high magnitude coefficients for a classifier fit on a dataset of movie reviews @xcite , where class 1 means positive sentiment and -1 means negative sentiment. we will return shortly to the meaning of the x-axis; for now, let us consider the y-axis, which is the estimated coefficient θ w for each word. of the four words strongly correlated with the positive class (θ @xmath4, two seem genuine (enjoyable, masterpiece), while two seem spurious (animated, spielberg). (steven spielberg is a very successful american director and producer.) similarly, of the words correlated with the negative class, two seem genuine (boring, failure) and two seem spurious (heavy, seagal). (steven seagal is an american actor mostly known for martial-arts movies.) furthermore, in some cases, the spurious term actually has a larger magnitude of coefficient than the genuine term (e.g., seagal versus failure). our goal in this paper is to distinguish between spurious and genuine correlations. without wading into long-standing debates over the nature of causality @xcite , we simplify the distinction between genuine and spurious correlations as a dichotomous decision: the discovered relationship between word w and label y is genuine if, all else being equal, one would expect w to be a determining factor in assigning a label to a sentence. we use human annotators to make this distinction for training and evaluating models. in this light, our problem is related to prior work on active learning with rationales @xcite and interactive feature selection @xcite . however, our goal is not solely to improve prediction accuracy, but also to improve robustness across different groups affected by these spurious correlations. ## methods our definition of genuine correlation given above fits well within the counterfactual framework of causal inference @xcite . if the word w in s were replaced with some other word w , how likely is it that the label y would change? since conducting randomized control trials to answer this counterfactual for many terms and sentences is infeasible, we instead resort to matching methods, commonly used to estimate average treatment effects from observational data @xcite . the intuition is as follows: if w is a reliable piece of evidence to determine the label of s, we should be able to find a very similar sentence s that (i) does not contain w, and (ii) has the opposite label of s. while this is not a necessary condition (there may not be a good match in a limited training set), in the experiments below we find this to be a fairly precise approach to identify genuine correlations. paul (2017) proposed a similar formulation, using propensity score matching to estimate the treatment effect for each term, then performing feature selection based on these estimates. beyond recent critiques of propensity scores @xcite , any matching approach will create matches of varying quality, making it difficult to distinguish between spurious and genuine correlations. returning to figure 1 , the x-axis shows the average quality of the counterfactual match for each term, where a larger value means that the linguistic context of the counterfactual sentence is very similar to the original sentence. (these are computed by cosine similarity of sentence embeddings, described in §3.2.) even though these terms have very similar average treatment effect estimates, the quality of the match seems to be a viable signal of whether the term is spurious or genuine. more generally, building on prior work that treats causal inference as a classification problem @xcite , we can derive a number of features from the components of the treatment effect estimates (enumerated in §3.3), and from these fit a classification model to determine whether a word should be labeled as spurious or genuine. this word classifier can then be used in a number of ways to improve the document classifier (e.g., to inform feature selection, to place priors on word coefficients, etc.). to build the word classifier, we assume a human has annotated a small number of terms as spurious or genuine, which we can use as training data. while this places an additional cost on annotation, the nature of the features reduces this burdenthere are not very many features in the word classifier, and they are mostly generic / domain independent. as a result, in the experiments below, we find that useful word classifiers can be built from a small number of labeled terms . furthermore, and perhaps more importantly, we find that the word classifier can be transported to new domains with little loss in accuracy. this suggests that one can label words once in one domain, fit a word classifier, and apply it in new domains without annotating additional words. ## results and discussion in this section, we show results for identifying spurious correlations and then analyze the effect of removing spurious correlations in different cases. ## conclusion we have proposed a supervised classification method to distinguish spurious and genuine correlations in text classification. using features derived from matched samples, we find that this word classifier achieves moderate to high accuracy even tested on strongly correlated terms. additionally, due to the generic nature of the features, we find that this classifier does not suffer much degradation in accuracy when trained on one dataset and applied to another dataset. finally, we use this word classifier to inform feature selection for document classification tasks. results show that removing words in the order of their predicted probability of being spurious results in more robust classification with respect to worst-case accuracy.