Title: Spuriosity Didn’t Kill the Classifier: Using Invariant Predictions to Harness Spurious Features
Venue: NeurIPS 2023
Accepted: yes
Keywords: invariant prediction

spurious correlations

out-of-distribution generalization

domain generalization

domain adaptation

test-time domain adaptation
Abstract: To avoid failures on out-of-distribution data, recent works have sought to extract features that have an invariant or stable relationship with the label across domains, discarding "spurious" or unstable features whose relationship with the label changes across domains. However, unstable features often carry complementary information that could boost performance if used correctly in the test domain. In this work, we show how this can be done without test-domain labels. In particular, we prove that pseudo-labels based on stable features provide sufficient guidance for doing so, provided that stable and unstable features are conditionally independent given the label. Based on this theoretical insight, we propose Stable Feature Boosting (SFB), an algorithm for: (i) learning a predictor that separates stable and conditionally-independent unstable features; and (ii) using the stable-feature predictions to adapt the unstable-feature predictions in the test domain. Theoretically, we prove that SFB can learn an asymptotically-optimal predictor without test-domain labels. Empirically, we demonstrate the effectiveness of SFB on real and synthetic data.

Spuriosity Didn't Kill the Classifier: Using Invariant Predictions to Harness Spurious Features

Abstract

To avoid failures on out-of-distribution data, recent works have sought to extract features that have an invariant or stable relationship with the label across domains, discarding 'spurious' or unstable features whose relationship with the label changes across domains. However, unstable features often carry complementary information that could boost performance if used correctly in the test domain. In this work, we show how this can be done without test-domain labels . In particular, we prove that pseudo-labels based on stable features provide sufficient guidance for doing so, provided that stable and unstable features are conditionally independent given the label. Based on this theoretical insight, we propose Stable Feature Boosting (SFB), an algorithm for: (i) learning a predictor that separates stable and conditionallyindependent unstable features; and (ii) using the stable-feature predictions to adapt the unstable-feature predictions in the test domain. Theoretically, we prove that SFB can learn an asymptotically-optimal predictor without test-domain labels. Empirically, we demonstrate the effectiveness of SFB on real and synthetic data.

1 Introduction

Machine learning systems can be sensitive to distribution shift [26]. Often, this sensitivity is due to a reliance on 'spurious' features whose relationship with the label changes across domains, ultimately leading to degraded performance in the test domain of interest [21]. To avoid this pitfall, recent works on domain or out-of-distribution (OOD) generalization have sought predictors which only make use of features that have a stable or invariant relationship with the label across domains, discarding the spurious or unstable features [45, 1, 35, 15]. However, despite their instability, spurious features can often provide additional or complementary information about the target label. Thus, if a predictor could be adjusted to use spurious features optimally in the test domain, it would boost performance substantially. That is, perhaps we don't need to discard spurious features at all but rather use them in the right way .

As a simple but illustrative example, consider the ColorMNIST or CMNIST dataset [1]. This transforms the original MNIST dataset into a binary classification task (digit in 0-4 or 5-9) and then: (i) flips the label with probability 0.25, meaning that, across all 3 domains, digit shape correctly determines the label with probability 0.75; and (ii) colorizes the digit such that digit color (red or green) is a more informative but spurious feature (see Fig. 1a). Prior work focused on learning an invariant predictor that uses only shape and avoids using color-a spurious feature whose relationship with the label changes across domains. However, as shown in Fig. 1b, the invariant predictor is suboptimal test domains where color can be used in a domain-specific manner to improve performance. We thus ask: when and how can such informative but spurious features be safely harnessed without labels ?

1

.

00

Test

0.9

0.8

-0.9

(Color-Label Correlation)

(a)

1.0

0.0

-1.0

Color-Label Correlation

0

.

50

0

.

75

ERM

Invariant

Optimal

(b)

(c)

Our main contribution lies in answering this question, showing when and how it is possible to safely harness spurious or unstable features without test-domain labels. In particular, we prove that predictions based on stable features provide sufficient guidance for doing so, provided that stable and unstable features are conditionally independent given the label (see Fig. 1c).

Structure and contributions. The rest of this paper is organized as follows. We first discuss related work in § 2, providing context and high-level motivation for our approach. In § 3, we then explain how stable and unstable features can be extracted, how unstable features can be harnessed with test-domain labels, and the questions/challenges that arise when trying to harness unstable features without test-domain labels. In § 4, we present our main theoretical contributions which provide precise answers to these questions, before using these insights to propose the Stable Feature Boosting (SFB) algorithm in § 5. In § 6, we present our experimental results, before ending with a discussion and concluding remarks in § 7. Our contributions can be summarized as follows:

Algorithmic: We propose Stable Feature Boosting (SFB), the first algorithm for using invariant predictions to safely harness spurious features without test-domain labels .

Theoretical: SFB is grounded in a novel theoretical result (Thm 4.4) giving sufficient conditions for provable test-domain adaptation without labels. Under these conditions, Thm 4.6 shows that, given enough unlabeled data, SFB learns the Bayes-optimal adapted classifier in the test domain.

Experimental: Our experiments on synthetic and real-world data demonstrate the effectiveness of SFB-even in scenarios where it is unclear if its assumptions are fully satisfied.

2 Related Work

Domain generalization, robustness and invariant prediction. A fundamental starting point for work in domain generalization is the observation that certain 'stable' features, often direct causes of the label, may have an invariant relationship with the label across domains [45, 1, 67, 55, 40, 77, 14]. However, such stable or invariant predictors often discard highly informative but unstable information. Rothenhäusler et al. [51] show that we may need to trade off stability and predictiveness, while Eastwood et al. [15] seek such a trade-off via an interpretable probability-of-generalization parameter. The current work is motivated by the idea that one might avoid such a trade-off by changing how unstable features are used at test time, rather than discarding them at training time.

Test-domain adaptation without labels (unsupervised domain adaptation). In the source-free and test-time domain adaptation literature, it is common to adapt to new domains using a model's own pseudo-labels [20, 36, 39, 71, 30]-see Rusak et al. [52] for a recent review. In contrast, we: (i) use one (stable) model to provide reliable/robust pseudo-labels and another (unstable) model to adapt domain-specific information; and (ii) propose a bias correction step that provably ensures an accurate, well-calibrated unstable model ( Pr [ Y | XU ] ) as well as an optimal joint/combined model ( Pr [ Y | XS , XU ] ). Beyond this literature, Bui et al. [12] propose a meta-learning approach for exploiting unstable/domain-specific features. However, they use unstable features in the same way in the test domain, which, by definition, is not robust and can degrade performance. Sun et al. [63] share the goal of exploiting unstable features to go 'beyond invariance'. However, in contrast to our approach, they require labels for the unstable features (rarely available) and only address label shifts.

Test-domain adaptation with labels (few-shot fine-tuning). Fine-tuning part of a model using a small number of labeled test-domain examples is a common way to deal with distribution shift [16, 17, 13]. More recently, it has been shown that simply retraining the last layer of an ERM-trained model outperforms more robust feature-learning methods on spurious correlation benchmarks [50, 32, 74]. Similar to our approach, Jiang and Veitch [31] separate stable and conditionally-independent unstable features and then adapt their use of the latter in the test domain. However, in contrast to our approach, theirs requires test-domain labels. In addition, they assume data is drawn from an anti-causal generative model, which is strictly stronger than our 'complementarity' assumption (see § 4).

Table 1 summarizes related work while App. H discusses further related work.

3 Problem Setup: Extracting and Harnessing Unstable Features

Setup. We consider the problem of domain generalization (DG) [8, 42, 24] where predictors are trained on data from multiple training domains and with the goal of performing well on data from unseen test domains. More formally, we consider datasets D e = { ( X e i , Y e i ) } ne i = 1 collected from m different training domains or environments E tr : = { E 1 , . . . , Em } , with each dataset D e containing data pairs ( X e i , Y e i ) sampled i.i.d. from P ( X e , Y e ) . 2 The goal is then to learn a predictor f ( X ) that performs well on a larger set E all ⊃ E tr of possible domains.

Average performance: use all features. The first approaches to DG sought predictors that perform well on average over domains [8, 42] using empirical risk minimization (ERM, [66]). However, predictors that perform well on average provably lack robustness [43, 49], potentially performing quite poorly on large subsets of E all . In particular, minimizing the average error leads predictors to make use of any features that are informative about the label (on average), including 'spurious' or 'shortcut' [21] features whose relationship with the label is subject to change across domains. In test domains where these feature-label relationships change in new or more severe ways than observed during training, this usually leads to significant performance drops or even complete failure [73, 4].

Worst-case or robust performance: use only stable features. To improve robustness, subsequent works sought predictors that only use stable or invariant features, i.e., those that have a stable or invariant relationship with the label across domains [45, 1, 47, 70, 58]. For example, Arjovsky et al. [1] do so by enforcing that the classifier on top of these features is optimal for all domains simultaneously. We henceforth use stable features and XS to refer to these features, and stable predictors to refer to predictors which use only these features. Analogously, we use unstable features and XU to refer to features with an unstable or 'spurious' relationship with the label across domains. Note that XS and XU partition the components of X which are informative about Y , as depicted in Fig. 1c, and that formal definitions of XS and XU are provided in § 4.

3.1 Harnessing unstable features with labels

A stable predictor f S is unlikely to be the best predictor in any given domain. As illustrated in Fig. 1b, this is because it excludes unstable features XU which are informative about Y and can boost performance if used in an appropriate, domain-specific manner . Assuming we can indeed learn a stable predictor with prior methods, we start by showing how XU can be harnessed with test-domain labels .

Boosting the stable predictor. We describe boosted joint predictions f e ( X ) in domain e as some combination C of stable predictions f S ( X ) and domain-specific unstable predictions f e U ( X ) , i.e., f e ( X ) = C ( f S ( X ) , f e U ( X )) . To allow us to adapt only the XU -Y relation, we decompose the stable f S ( X ) = hS ( Φ S ( X )) and unstable f e U ( X ) = h e U ( Φ U ( X )) predictions into feature extractors Φ and classifiers h . Φ S extracts stable components XS = Φ S ( X ) of X , Φ U extracts unstable components XU = Φ U ( X ) of X , hS is a classifier learned on top of Φ S (shared across domains), and h e U is a domain-specific unstable classifier learned on top of Φ U (one per domain). Putting these together,

where C : [ 0, 1 ] × [ 0, 1 ] → [ 0, 1 ] is a combination function that combines the stable and unstable predictions. For example, Jiang and Veitch [31, Eq. 2.1] add stable pS and unstable pU predictions in logit space, i.e., C ( pS , pU ) = σ ( logit ( pS ) + logit ( pU )) . Since it is unclear, a priori , how to choose C , we will leave it unspecified until Thm. 4.4 in § 4, where we derive a principled choice.

Adapting with labels. Given a new domain e and labels Y e , we can boost performance by adapting h e U . Specifically, letting ℓ : Y × Y → R be a loss function (e.g., cross-entropy) and R e ( f ) = E ( X , Y ) [ ℓ ( Y , f ( X )) | E = e ] the risk of predictor f : X → Y in domain e , we can adapt h e U to solve:

3.2 Harnessing unstable features without labels

We now consider the main question of this work-can we reliably harness XU without test-domain labels? We could, of course, simply select a fixed unstable classifier h e U by relying solely on the training domains (e.g., by minimizing average error), and hope that this works for the test-domain XU -Y relation. However, by definition of XU being unstable, this is clearly not a robust or reliable approach-the focus of our efforts in this work, as illustrated in Table 1. As in § 3.1, we assume that we are able to learn a stable predictor f S using prior methods, e.g., IRM [1] or QRM [15].

From stable predictions to robust pseudo-labels. While we don't have labels in the test domain, we do have stable predictions. By definition, these are imperfect (i.e., noisy ) but robust, and can be used to form pseudo-labels ̂ Yi = arg max j ( f S ( Xi )) j , with ( f S ( Xi )) j ≈ Pr [ Yi = j | XS ] denoting the j th entry of the stable prediction for Xi . Can we somehow use these noisy but robust pseudo-labels to guide our updating of h e U , and, ultimately, our use of XU in the test domain?

From joint to unstable-only risk. If we simply use our robust pseudo-labels as if they were true labels-updating h e U to minimize the joint risk as in Eq. (3.2)-we arrive at trivial solutions since fS already predicts its own pseudo-labels with 100% accuracy. For example, if we follow [31, Eq. 2.1] and use the combination function C ( pS , pU ) = σ ( logit ( pS ) + logit ( pU )) , then the trivial solution logit ( h e U ( · ))= 0 achieves 100% accuracy (and minimizes cross-entropy; see Prop. D.1 of App. D). Thus, we cannot minimize a joint loss involving f S 's predictions when using f S 's pseudo-labels. A sensible alternative is to update h e U to minimize the unstable-only risk R e ( h e U ◦ Φ U ) .

More questions than answers. While this new procedure could work, it raises questions about when it will work, or, more precisely, the conditions under which it can be used to safely harness XU . We now summarise these questions before addressing them in § 4:

Does it make sense to minimize the unstable-only risk? In particular, when can we minimize the unstable-predictor risk alone or separately, and then arrive at the optimal joint predictor? This cannot always work; e.g., for independent XS , XU ∼ Bernoulli ( 1/2 ) and Y = XS XOR XU , Y is independent of each of XS and XU and hence cannot be predicted from either alone.

How should we combine predictions? Is there a principled choice for the combination function C in Eq. (3.1)? In particular, is there a C that correctly weights stable and unstable predictions in the test domain? As XU could be very strongly or very weakly predictive of Y in the test domain, this seems a difficult task. Intuitively, correctly weighting stable and unstable predictions requires them to be properly calibrated: do we have any reason to believe that, after training on f S 's pseudo-labels, h e U will be properly calibrated in the test domain?

Can the student outperform the teacher? Stable predictions likely make mistakes-indeed, this is the motivation for trying to improve them. Is it possible to correct these mistakes with XU ? Is it

possible to learn an unstable 'student' predictor that outperforms its own supervision signal or 'teacher'? Perhaps surprisingly, we show that, for certain types of features, the answer is yes. In fact, even a very weak stable predictor, with performance just above chance, can be used to learn an optimal unstable classifier in the test domain given enough unlabeled data.

4 Theory: When Can We Safely Harness Unstable Features Without Labels?

Suppose we have already identified a stable feature XS and a potentially unstable feature XU (we will return to the question of how to learn/extract XS and XU themselves in § 5). In this section, we analyze the problem of using XS to leverage XU in the test domain without labels. We first reduce this to a special case of the so-called 'marginal problem' in probability theory, i.e., the problem of identifying a joint distribution based on information about its marginals. In the special case where two variables are conditionally independent given a third, we show this problem can be solved exactly. This solution, which may be of interest beyond the context of domain generalization/adaptation, motivates our test-domain adaptation algorithm (Alg. 1), and forms the basis of Thm. 4.6 which shows that Alg. 1 converges to the best possible classifier given enough unlabeled data.

We first pose a population-level model of our domain generalization setup. Let E be a random variable denoting the environment . Given an environment E , we have that the stable feature XS , unstable feature XU and label Y are distributed according to PXS , XU , Y | E . We can now formalize the three key assumptions underlying our approach, starting with the notion of a stable feature, motivated in § 3:

Definition 4.1 (Stable and Unstable Features) . XS is a stable feature with respect to Y if P Y | XS does not depend on E ; equivalently, if Y and E are conditionally independent given XS ( Y ⊥ ⊥ E | XS ). Conversely, XU is an unstable feature with respect to Y if P Y | XU depends on E ; equivalently, if Y and E are conditionally dependent given XU ( Y ̸ ⊥ ⊥ E | XU ).

Next, we state our complementarity assumption, which we will show justifies the approach of separately learning the relationships XS -Y and XU -Y and then combining them:

Definition 4.2 (Complementary Features) . XS and XU are complementary features with respect to Y if XS ⊥ ⊥ XU | ( Y , E ) ; i.e., if XS and XU share no redundant information beyond Y and E .

Finally, to provide a useful signal for test-domain adaptation, the stable feature needs to help predict the label in the test domain. Formally, we assume:

Definition 4.3 (Informative Feature) . XS is said to be informative of Y in environment E if XS ̸ ⊥ ⊥ Y | E ; i.e., XS is predictive of Y within the environment E .

We will discuss the roles of these assumptions after stating our main result (Thm. 4.4) that uses them. To keep our results as general as possible, we avoid assuming a particular causal generative model, but the above conditional (in)dependence assumptions can be interpreted as constraints on such a causal model. App. D.2 formally characterizes the set of causal models that are consistent with our assumptions and shows that our setting generalizes those of prior works [49, 68, 31, 69].

Reduction to the marginal problem with complementary features. By Defn. 4.1, we have the same stable relationship P Y | XS , E = P Y | XS in training and test domains. Now, suppose we have used the training data to learn this stable relationship and thus know P Y | XS . Also suppose that we have enough unlabeled data from test domain E to learn PXS , XU | E , and recall that our ultimate goal is to predict Y from ( XS , XU ) in test domain E . Since the rest of our discussion is conditioned on E being the test domain, we omit E from the notation. Now note that, if we could express P Y | XS , XU in terms of P Y | XS and PXS , XU , we could then use P Y | XS , XU to optimally predict Y from ( XS , XU ) . Thus, our task thus becomes to reconstruct P Y | XS , XU from P Y | XS and PXS , XU . This is an instance of the classical 'marginal problem' from probability theory [28, 29, 19], which asks under which conditions we can recover the joint distribution of a set of random variables given information about its marginals. In general, although one can place bounds on the conditional distributions P Y | XU and P Y | XS , XU , they cannot be completely inferred from P Y | XS and PXS , XU [19]. However, the following section demonstrates that, under the additional assumptions that XS and XU are complementary and XS is informative , we can exactly recover P Y | XU and P Y | XS , XU from P Y | XS and PXS , XU .

4.1 Solving the marginal problem with complementary features

We now present our main result which shows how to reconstruct P Y | XS , XU from P Y | XS and PXS , XU when XS and XU are complementary and XS is informative. To simplify notation, we assume the label Y is binary and defer the multi-class extension to App. C.

Theorem 4.4 (Solution to the marginal problem with binary labels and complementary features) . Consider three random variables XS , XU , and Y , where (i) Y is binary ( { 0, 1 } -valued), (ii) XS and XU are complementary features for Y (i.e., XS ⊥ ⊥ XU | Y ), and (iii) XS is informative of Y ( XS ̸ ⊥ ⊥ Y ). Then, the joint distribution of ( XS , XU , Y ) can be written in terms of the joint distributions of ( XS , Y ) and ( XS , XU ) . Specifically, if ̂ Y | XS ∼ Bernoulli ( Pr [ Y = 1 | XS ]) is a pseudo-label 3 and

are the accuracies of the pseudo-labels on classes 0 and 1 , respectively. Then, we have:

Intuitively, suppose we generate pseudo-labels ̂ Y based on feature XS and train a model to predict ̂ Y using feature XU . For complementary XS and XU , Eq. (4.3) shows how to transform this into a prediction of the true label Y , correcting for differences between ̂ Y and Y . Crucially, given the conditional distribution P Y | XS and observations of XS , we can estimate class-wise pseudo-label accuracies ϵ 0 and ϵ 1 in Eq. (4.3) even without new labels Y (see App. A.1, Eq. (A.2)). Finally, Eq. (4.4) shows how to weight predictions based on XS and XU , justifying the combination function

in Eq. (3.1), where p = Pr [ Y = 1 ] is a constant independent of xS and xU . We now sketch the proof of Thm. 4.4, elucidating the roles of informativeness and complementarity (full proof in App. A.1).

Proof Sketch of Thm. 4.4. We prove Eq. (4.2), Eq. (4.3), and Eq. (4.4) in order.

Proof of Eq. (4.2): The informativeness condition (iii) is equivalent to the pseudo-labels having predictive accuracy above random chance; formally, App. A.1 shows:

Lemma 4.5. ϵ 0 + ϵ 1 > 1 if and only if XS is informative of Y (i.e., XS ̸ ⊥ ⊥ Y ).

Together with Eq. (4.3), it follows that any dependence between XS and Y allows us to fully learn the relationship between XU and Y , affirmatively answering our question from § 3: Can the student outperform the teacher? While a stronger relationship between XS and Y is still helpful, it only improves the (unlabeled) sample complexity of learning P Y | XU and not consistency (Thm. 4.6 below), mirroring related results in the literature on learning from noisy labels [44, 7]. In particular, a weak relationship corresponds to ϵ 0 + ϵ 1 ≈ 1 , increasing the variance of the bias-correction in Eq. (4.3). With a bit more work, one can formalize this intuition to show that our approach has a relative statistical efficiency of ϵ 0 + ϵ 1 -1 ∈ [ 0, 1 ] , compared to using true labels Y .

Proof of Eq. (4.3): The key observation behind the bias-correction (Eq. (4.3)) is that, due to complementarity ( XS ⊥ ⊥ XU | Y ) and the fact that the pseudo-label ̂ Y depends only on XS , ̂ Y is conditionally independent of XU given the true label Y ( ̂ Y ⊥ ⊥ XU | Y ); formally:

Algorithm 1: Bias-corrected adaptation procedure. Multi-class version given by Algorithm 2.

Input: Calibrated stable classifier f S ( xS ) = Pr [ Y = 1 | XS = xS ] , unlabelled data { ( XS , i , XU , i ) } n i = 1

Output: Joint classifier ̂ f ( xS , xU ) estimating Pr [ Y = 1 | XS = xS , XU = xU ]

1 Compute soft pseudo-labels (PLs) { ̂ Yi } n i = 1 with ̂ Yi = f S ( XS , i )

3 Estimate PL accuracies ( ̂ ϵ 0 , ̂ ϵ 1 ) = ( 1 n -n 1 ∑ n i = 1 ( 1 -̂ Yi )( 1 -f S ( XS , i )) , 1 n 1 ∑ n i = 1 ̂ Yi f S ( XS , i ) ) // Eq. (4.1)

2 Compute soft class-1 count n 1 = ∑ n i = 1 ̂ Yi

4 Fit unstable classifier ˜ fU ( xU ) to pseudo-labelled data { ( XU , i , ̂ Yi ) } n i = 1 // ≈ Pr [ ̂ Y = 1 | XU = xU ]

5 Bias-correct ̂ fU ( xU ) ↦→ max { 0, min { 1, ˜ fU ( xU )+ ̂ ϵ 0 -1 ̂ ϵ 0 + ̂ ϵ 1 -1 }} // Eq. (4.3) , ≈ Pr [ Y = 1 | XU = xU ]

6 return ̂ f ( xS , xU ) ↦→ C n 1 n ( f S ( xS ) , ̂ fU ( xU )) // Eq. (4.4) / (4.5) , ≈ Pr [ Y = 1 | XS = xS , XU = xU ]

Here, complementarity allowed us to approximate the unknown Pr [ ̂ Y = 1 | Y = 0, XU ] by its average Pr [ ̂ Y = 1 | Y = 0 ] = E XU [ Pr [ ̂ Y = 1 | Y = 0, XU ]] , which depends only on the known distribution PXS , Y . By informativeness, Lemma 4.5 allows us to divide by ϵ 0 + ϵ 1 -1 , giving Eq. (4.3).

Proof of Eq. (4.4): While the exact proof of Eq. (4.4) is a bit more algebraically involved, the key idea is simply that complementarity allows us to decompose Pr [ Y | XS , XU ] into separatelyestimatable terms Pr [ Y | XS ] and Pr [ Y | XU ] : for any y ∈ Y ,

where, ∝ XS , XU denotes proportionality with a constant depending only on XS and XU , not on y . Directly estimating these constants involves estimating the density of ( XS , XU ) , which may be intractable without further assumptions. However, in the binary case, since 1 -Pr [ Y = 1 | XS , XU ] = Pr [ Y = 0 | XS , XU ] , these proportionality constants conveniently cancel out when the above relationship is written in logit -space, as in Eq. (4.4). In the multi-class case, App. C shows how to use the constraint ∑ y ∈Y Pr [ Y = y | XS , XU ] = 1 to avoid computing the proportionality constants.

4.2 A provably consistent algorithm for unsupervised test-domain adaptation

Having learned P Y | XS from the training domain(s), Thm. 4.4 implies we can learn P Y | XS , XU in the test domain by learning PXS , XU -the latter only requiring unlabeled test-domain data. This motivates our Alg. 1 for test-domain adaptation, which is a finite-sample version of the bias-correction and combination equations (Eqs. (4.3) and (4.4)) in Thm. 4.4. Alg. 1 comes with the following guarantee:

Theorem 4.6 (Consistency Guarantee, Informal) . Assume (i) XS is stable, (ii) XS and XU are complementary, and (iii) XS is informative of Y in the test domain. As n → ∞ , if ˜ fU → Pr [ ̂ Y = 1 | XU ] then ̂ f → Pr [ Y = 1 | XS , XU ] .

In words, as the amount of unlabeled data from the test domain increases, if the unstable classifier on Line 4 of Alg. 1 learns to predict the pseudo-label ̂ Y , then the joint classifier output by Alg. 1 learns to predict the true label Y . Convergence in Thm. 4.6 occurs PXS , XU -a.e., both weakly (in prob.) and strongly (a.s.), depending on the convergence of ˜ fU . Formal statements and proofs are in Appendix B.

5 Algorithm: Stable Feature Boosting (SFB)

Using theoretical insights from § 4, we now propose Stable Feature Boosting (SFB): an algorithm for safely harnessing unstable features without test-domain labels. We first describe learning a stable predictor and extracting complementary unstable features from the training domains. We then describe how to use these with Alg. 1, adapting our use of the unstable features to the test domain.

Training domains: Learning stable and complementary features. Using the notation of Eq. (3.1), our goal on the training domains is to learn stable and unstable features Φ S and Φ U , a stable predictor f S , and domain-specific unstable predictors f e U such that:

f S is stable, informative, and calibrated (i.e., f S ( xS ) = Pr [ Y = 1 | XS = xS ] ).

In domain e , f e U boosts f s 's performance with complementary Φ U ( X e ) ⊥ ⊥ Φ S ( X e ) | Y e .

To achieve these learning goals, we propose the following objective:

The first term encourages good stable predictions f S ( X ) = hS ( Φ S ( X )) while the second encourages improved domain-specific joint predictions f e ( X e ) = C ( hS ( Φ S ( X e )) , h e U ( Φ U ( X e ))) via a domainspecific use h e U of the unstable features Φ U ( X e ) . For binary Y , the combination function C takes the simplified form of Eq. (4.5). Otherwise, C takes the more general form of Eq. (C.1). P Stability is a penalty encouraging stability while P CondIndep is a penalty encouraging complementarity or conditional independence, i.e., Φ U ( X e ) ⊥ ⊥ Φ S ( X e ) | Y e . Several approaches exist for enforcing stability [1, 35, 58, 47, 15, 67, 40, 77] (e.g., IRM [1]) and conditional independence (e.g., conditional HSIC [22]). λ S ∈ [ 0, ∞ ) and λ C ∈ [ 0, ∞ ) are regularization hyperparameters. While another hyperparameter γ ∈ [ 0, 1 ] could control the relative weighting of stable and joint risks, i.e., γ R e ( hS ◦ Φ S ) and ( 1 -γ ) R e ( C ( hS ◦ Φ S , h e U ◦ Φ U )) , we found this unnecessary in practice. Finally, note that, in principle, h e U could take any form and we could learn completely separate Φ S , Φ U . In practice, we simply take h e U to be a linear classifier and split the output of a shared Φ ( X ) = ( Φ S ( X ) , Φ U ( X )) .

Post-hoc calibration. As noted in § 4.2, the stable predictor f S must be properly calibrated to (i) form unbiased unstable predictions (Line 5 of Alg. 1) and (ii) correctly combine the stable and unstable predictions (Line 6 of Alg. 1). Thus, after optimizing the objective (5.1), we apply a post-processing step (e.g., temperature scaling [25]) to calibrate f S .

Test-domain adaptation without labels. Given a stable predictor f S = hS ◦ Φ S and complementary features Φ U ( X ) , we now adapt the unstable classifier h e U in the test domain to safely harness (or make optimal use of) Φ U ( X ) . To do so, we use the bias-corrected adaptation algorithm of Alg. 1 (or Alg. 2 for the multi-class case) which takes as input the stable classifier hS 4 and unlabelled test-domain data { Φ S ( xi ) , Φ U ( xi ) } ne i = 1 , outputting a joint classifier adapted to the test domain.

6 Experiments

We now evaluate the performance of our algorithm on synthetic and real-world datasets requiring outof-distribution generalization. App. E contains full details on these datasets and a depiction of their samples (see Fig. 4). In the experiments below, SFB uses IRM [1] for P Stability and the conditionalindependence proxy of Jiang and Veitch [31, §3.1] for P CondIndep , with App. F.1.2 giving results with other stability penalties. App. F contains further results, including ablation studies (F.1.1) and results on additional datasets (F.2). In particular, App. F.2 contains results on the Camelyon17 medical dataset [3] from the WILDS package [33], where we find that all methods perform similarly when properly tuned (see discussion in App. F.2). Code is available at: https://github.com/cianeastwood/sfb.

Synthetic data. We consider two synthetic datasets: anti-causal (AC) data and cause-effect data with direct XS -XU dependence (CE-DD). AC data satisfies the structural equations

β

e

XS

Y

XU

where the input X = ( XS , XU ) and Rad ( β ) denotes a Rademacher random variable that

Synthetic

PACS

Algorithm

AC

CE-DD

P

A

C

S

ERM

9.9

±

0.1

11.6

±

0.7

93.0

±

0.7

79.3

±

0.5

74.3

±

0.7

65.4

±

1.5

ERM + PL

9.9

±

0.1

11.6

±

0.7

93.7

±

0.4

79.6

±

1.5

74.1

±

1.2

63.1

±

3.1

IRM [1]

74.9

±

0.1

69.6

±

1.3

93.3

±

0.3

78.7

±

0.7

75.4

±

1.5

65.6

±

2.5

IRM + PL

74.9

±

0.1

69.6

±

1.3

94.1

±

0.7

78.9

±

2.9

75.1

±

4.6

62.9

±

4.9

ACTIR [31]

74.8

±

0.4

43.5

±

2.6

94.8

±

0.1

82

.

5

±

0

.

4

76

.

6

±

0

.

6

62.1

±

1.3

SFB no adpt.

74.7

±

1.2

74.9

±

3.6

93.7

±

0.6

78.1

±

1.1

73.7

±

0.6

69.7

±

2.3

SFB

89

.

2

±

2

.

9

88

.

6

±

1

.

4

95

.

8

±

0

.

6

80.4

±

1.3

76

.

6

±

0

.

6

71

.

8

±

2

.

0

Algorithm

Test Acc.

ERM

27.9

±

1.5

IRM [1]

69.7

±

0.9

SFB no adpt.

70.6

±

1.8

SFB

88

.

1

±

1

.

8

Oracle no adpt.

72.1

±

0.7

Oracle

89.9

±

0.1

0.9

0.0

-0.9

Color-Label Correlation

0.65

0.70

0.75

0.80

0.85

0.90

IRM

IRM + PL

IRM + T3A

SFB

ERM

0.9

0.0

-0.9

Color-Label Correlation

SFB w/o Rn,CA,BC

SFB w/o Rn,CA

SFB w/o Rn

Oracle

SFB no adpt

SFB

is -1 with probability 1 -β and + 1 with probability β . Following [31, §6.1], we create two training domains with β e ∈ { 0.95, 0.7 } , one validation domain with β e = 0.6 and one test domain with β e = 0.1 . CE-DD data is generated according to the structural equations

where Bern ( β ) denotes a Bernoulli random variable that is 1 with probability β and 0 with probability 1 -β . Note that XS ̸ ⊥ ⊥ XU | Y , since XS directly influences XU . Following [31, App. B], we create two training domains with β e ∈ { 0.95, 0.8 } , one validation domain with β e = 0.2 , and one test domain with β e = 0.1 . For both datasets, the idea is that, during training, prediction based on the stable XS results in lower accuracy (75%) than prediction based on the unstable XU . Thus, models optimizing for prediction accuracy only-and not stability-will use XU and ultimately end up with only 10% in the test domain. Importantly, while the stable predictor achieves 75% accuracy in the test domain, this can be improved to 90% if XU is used correctly. Following [31], we use a simple 3-layer network for both datasets and choose hyperparameters using the validation-domain performance: see App. G.2 for further implementation details.

On the AC dataset, Table 2 shows that ERM performs poorly as it misuses XU , while IRM, ACTIR, and SFB-no-adpt. do well by using only XS . Critically, only SFB (with adaptation) is able to harness XU in the test domain without labels , leading to a near-optimal performance boost.

On the CE-DD dataset, Table 2 again shows that ERM performs poorly while IRM and SFB-no-adpt. do well by using only the stable XS . However, we now see that ACTIR performs poorly since its assumption of anti-causal structure no longer holds. This highlights another key advantage of SFB over ACTIR: any stability penalty can be used, including those with weaker assumptions than ACTIR's anti-causal structure (e.g., IRM). Perhaps more surprisingly, SFB (with adaptation) performs well despite the complementarity assumption XS ⊥ ⊥ XU | Y being violated. One explanation for this is that complementarity is only weakly violated in the test domain. Another is that complementarity is not necessary for SFB, with some weaker, yet-to-be-determined condition(s) sufficing. In App. I, we provide a more detailed explanation and discussion of this observation.

ColorMNIST. We now consider the ColorMNIST dataset [1], described in § 1 and Fig. 1a. We follow the experimental setup of Eastwood et al. [15, §6.1]; see App. G.3 for details. Table 3 shows that: (i) SFB learns a stable predictor ('no adpt.') with performance comparable to other stable/invariant

methods like IRM [1]; and (ii) only SFB (with adaptation) is capable of harnessing the spurious color feature in the test domain without labels , leading to a near-optimal boost in performance. Note that 'Oracle no adpt.' refers to an ERM model trained on grayscale images, while 'Oracle' refers to an ERM model trained on labeled test-domain data. Table 6 of App. F.1.3 compares to additional baseline methods, including V-REx [35], EQRM [15], Fishr [48] and more. Fig. 2 gives more insight by showing performance across test domains of varying color-label correlation. On the left, we see that SFB outperforms ERM and IRM, as well as additional adaptive baseline methods in IRM + pseudo-labeling (PL, [36]) and IRM + T3A [30] (see App. G.1 for details). On the right, ablations show that: (i) bias-correction (BC), post-hoc calibration (CA), and multiple rounds of pseudo-labeling (Rn) improve adaptation performance; and (ii) without labels, SFB harnesses the spurious color feature near-optimally in test domains of varying color-label correlation-the original goal we set out to achieve in Fig. 1b. Further results and ablations are provided in App. F.1.

PACS. Table 2 shows that SFB's stable ('no adpt.') performance is comparable to that of the other stable/invariant methods (IRM, ACTIR). One exception is the sketch domain (S)-the most severe shift based on performance drop-where SFB's stable predictor performs best. Another is on domains A and C, where ACTIR performs better than SFB's stable predictor. Most notable, however, is: (i) the consistent performance boost that SFB gets from unsupervised adaptation; and (ii) SFB performing best or joint-best on 3 of the 4 domains. These results suggest SFB can be useful on real-world datasets where it is unclear if complementarity holds. In App. I, we discuss why this may be the case.

7 Conclusion & Future Work

This work demonstrated, both theoretically and practically, how to adapt our usage of spurious features to new test domains using only a stable, complementary training signal. By using invariant predictions to safely harness complementary spurious features, our proposed Stable Feature Boosting algorithm can provide significant performance gains compared to only using invariant/stable features or using unadapted spurious features-without requiring any true labels in the test domain.

Stable and calibrated predictors. Perhaps the greatest challenge in applying SFB in practice is the need for a stable and calibrated predictor. While stable features may be directly observable in some cases (e.g., using prior knowledge of causal relationships between the domain, features, and label, as in Prop. D.2), they often need to be extracted from high-dimensional observations (e.g., images). Several methods for stable-feature extraction have recently been proposed [1, 35, 58, 70, 15], with future improvements likely to benefit SFB. Calibrating complex predictors like deep neural networks is also an active area of research [18, 25, 72, 59], with future improvements likely to benefit SFB.

Weakening the complementarity condition. SFB also assumes that stable and unstable features are complementarity, i.e., conditionally independent given the label. This assumption is implicit in the causal generative models assumed by prior work [49, 68, 31], and future work may look to weaken it. However, our experimental results suggest that SFB may be robust to violations of complementarity in practice: on our synthetic data where complementarity does not hold ( CE-DD ) and real data where we have no reason to believe it holds ( PACS ), SFB still outperformed baseline methods. We discuss potential reasons for this in App. I and hope that future work can identify weaker sufficient conditions.

Exploiting newly-available test-domain features without labels. While we focused on domain generalization (DG) and the goal of (re)learning how to use the same spurious features (e.g., color) in a new way, our solution to the 'marginal problem' in § 4.1 can be used to exploit a completely new set of (complementary) features in the test domain that weren't available in the training domains. For example, given a stable predictor of diabetes based on causal features (e.g., age, genetics), SFB could exploit new unlabeled data containing previously-unseen effect features (e.g., glucose levels). We hope future work can explore such uses of SFB.

Acknowledgments and Disclosure of Funding

The authors thank Chris Williams and Ian Mason for providing feedback on an earlier draft, as well as the MPI Tübingen causality group for helpful discussions and comments. This work was supported by the Tübingen AI Center (FKZ: 01IS18039B) and by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy - EXC number 2064/1 - Project number 390727645. The authors declare no competing interests.

References

Arjovsky, M., Bottou, L., Gulrajani, I., and Lopez-Paz, D. (2020). Invariant risk minimization. arXiv:1907.02893. [Cited on pages 1, 2, 3, 4, 8, 9, 10, 26, 27, 29, and 31.]

Ba, J. and Caruana, R. (2014). Do deep nets really need to be deep? Advances in Neural Information Processing Systems , 27. [Cited on page 19.]

Bandi, P., Geessink, O., Manson, Q., Van Dijk, M., Balkenhol, M., Hermsen, M., Bejnordi, B. E., Lee, B., Paeng, K., Zhong, A., et al. (2018). From detection of individual metastases to classification of lymph node status at the patient level: the camelyon17 challenge. IEEE Transactions on Medical Imaging , 38(2):550-560. [Cited on pages 8, 27, 28, and 29.]

Beery, S., Van Horn, G., and Perona, P. (2018). Recognition in terra incognita. In Proceedings of the European Conference on Computer Vision , pages 456-473. [Cited on page 3.]

Ben-David, S., Blitzer, J., Crammer, K., Kulesza, A., Pereira, F., and Vaughan, J. W. (2010). A theory of learning from different domains. Machine Learning , 79(1):151-175. [Cited on page 32.]

Bickel, S., Brückner, M., and Scheffer, T. (2009). Discriminative learning under covariate shift. Journal of Machine Learning Research , 10(9). [Cited on page 26.]

Blanchard, G., Flaska, M., Handy, G., Pozzi, S., and Scott, C. (2016). Classification with asymmetric label noise: Consistency and maximal denoising. Electronic Journal of Statistics , 10:2780-2824. [Cited on pages 6, 19, and 32.]

Blanchard, G., Lee, G., and Scott, C. (2011). Generalizing from several related classification tasks to a new unlabeled sample. In Advances in Neural Information Processing Systems , volume 24. [Cited on page 3.]

Blitzer, J., Crammer, K., Kulesza, A., Pereira, F., and Wortman, J. (2007). Learning bounds for domain adaptation. Advances in Neural Information Processing Systems , 20. [Cited on page 32.]

Blum, A. and Mitchell, T. (1998). Combining labeled and unlabeled data with co-training. In Proceedings of the eleventh annual conference on Computational learning theory , pages 92-100. [Cited on page 32.]

Buciluˇ a, C., Caruana, R., and Niculescu-Mizil, A. (2006). Model compression. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining , pages 535-541. [Cited on page 19.]

Bui, M.-H., Tran, T., Tran, A., and Phung, D. (2021). Exploiting domain-specific features to enhance domain generalization. In Advances in Neural Information Processing Systems , volume 34. [Cited on page 2.]

Eastwood, C., Mason, I., and Williams, C. (2021). Unit-level surprise in neural networks. In I (Still) Can't Believe It's Not Better! NeurIPS 2021 Workshop . [Cited on page 3.]

Eastwood, C., Mason, I., Williams, C., and Schölkopf, B. (2022a). Source-free adaptation to measurement shift via bottom-up feature restoration. In International Conference on Learning Representations . [Cited on page 2.]

Eastwood, C., Robey, A., Singh, S., von Kügelgen, J., Hassani, H., Pappas, G. J., and Schölkopf, B. (2022b). Probable domain generalization via quantile risk minimization. In Advances in Neural Information Processing Systems . [Cited on pages 1, 2, 3, 4, 8, 9, 10, 29, and 31.]

Fei-Fei, L., Fergus, R., and Perona, P. (2006). One-shot learning of object categories. IEEE Transactions on Pattern Analysis and Machine Intelligence , 28(4):594-611. [Cited on page 3.]

Finn, C., Abbeel, P., and Levine, S. (2017). Model-agnostic meta-learning for fast adaptation of deep networks. In International Conference on Machine Learning , pages 1126-1135. [Cited on page 3.]

Flach, P. A. (2016). Classifier calibration. In Encyclopedia of machine learning and data mining . Springer US. [Cited on page 10.]

Fréchet, M. (1951). Sur les tableaux de corrélation dont les marges sont données. Ann. Univ. Lyon, 3ˆ e serie, Sciences, Sect. A , 14:53-77. [Cited on page 5.]

Galstyan, A. and Cohen, P. R. (2008). Empirical comparison of 'hard' and 'soft' label propagation for relational classification. In Inductive Logic Programming: 17th International Conference, ILP 2007, Corvallis, OR, USA, June 19-21, 2007, Revised Selected Papers 17 , pages 98-111. Springer. [Cited on pages 2 and 6.]

Geirhos, R., Jacobsen, J.-H., Michaelis, C., Zemel, R., Brendel, W., Bethge, M., and Wichmann, F. A. (2020). Shortcut learning in deep neural networks. Nature Machine Intelligence , 2:665-673. [Cited on pages 1 and 3.]

Gretton, A., Bousquet, O., Smola, A., and Schölkopf, B. (2005). Measuring statistical dependence with Hilbert-Schmidt norms. In Algorithmic Learning Theory: 16th International Conference, ALT 2005, Singapore, October 8-11, 2005. Proceedings 16 , pages 63-77. Springer. [Cited on page 8.]

Gretton, A., Smola, A., Huang, J., Schmittfull, M., Borgwardt, K., and Schölkopf, B. (2009). Covariate shift by kernel mean matching. Dataset shift in machine learning , 3(4):5. [Cited on page 26.]

Gulrajani, I. and Lopez-Paz, D. (2020). In search of lost domain generalization. arXiv preprint arXiv:2007.01434 . [Cited on pages 3, 27, 30, and 31.]

Guo, C., Pleiss, G., Sun, Y., and Weinberger, K. Q. (2017). On calibration of modern neural networks. In International Conference on Machine Learning , pages 1321-1330. [Cited on pages 8, 10, 28, 31, and 32.]

Hendrycks, D. and Dietterich, T. (2019). Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations . [Cited on page 1.]

Hinton, G., Vinyals, O., and Dean, J. (2015). Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531 . [Cited on page 19.]

Hoeffding, W. (1940). Masstabinvariante korrelationstheorie. Schriften des Mathematischen Instituts und Instituts fur Angewandte Mathematik der Universitat Berlin , 5:181-233. [Cited on page 5.]

Hoeffding, W. (1941). Masstabinvariante korrelationsmasse für diskontinuierliche verteilungen. Archiv für mathematische Wirtschafts-und Sozialforschung , 7:49-70. [Cited on page 5.]

Iwasawa, Y. and Matsuo, Y. (2021). Test-time classifier adjustment module for model-agnostic domain generalization. In Advances in Neural Information Processing Systems . [Cited on pages 2, 10, 30, and 31.]

Jiang, Y. and Veitch, V. (2022). Invariant and transportable representations for anti-causal domain shifts. In Oh, A. H., Agarwal, A., Belgrave, D., and Cho, K., editors, Advances in Neural Information Processing Systems . [Cited on pages 3, 4, 5, 8, 9, 10, 25, 26, 27, 30, 31, and 32.]

Kirichenko, P., Izmailov, P., and Wilson, A. G. (2022). Last layer re-training is sufficient for robustness to spurious correlations. In Advances in Neural Information Processing Systems . [Cited on page 3.]

Koh, P. W., Sagawa, S., Marklund, H., Xie, S. M., Zhang, M., Balsubramani, A., Hu, W., Yasunaga, M., Phillips, R. L., Gao, I., Lee, T., David, E., Stavness, I., Guo, W., Earnshaw, B. A., Haque, I. S., Beery, S., Leskovec, J., Kundaje, A., Pierson, E., Levine, S., Finn, C., and Liang, P. (2021). WILDS: A benchmark of in-the-wild distribution shifts. In International Conference on Machine Learning . [Cited on pages 8, 27, and 32.]

Krogel, M.-A. and Scheffer, T. (2004). Multi-relational learning, text mining, and semisupervised learning for functional genomics. Machine Learning , 57:61-81. [Cited on page 32.]

Krueger, D., Caballero, E., Jacobsen, J.-H., Zhang, A., Binas, J., Zhang, D., Priol, R. L., and Courville, A. (2021). Out-of-distribution generalization via risk extrapolation (REx). In International Conference on Machine Learning , volume 139, pages 5815-5826. [Cited on pages 1, 8, 10, 29, and 31.]

Lee, D.-H. et al. (2013). Pseudo-label: The simple and efficient semi-supervised learning method for deep neural networks. In Workshop on Challenges in Representation Learning, ICML , volume 3. [Cited on pages 2, 6, 10, and 30.]

Li, D., Yang, Y., Song, Y.-Z., and Hospedales, T. M. (2017a). Deeper, broader and artier domain generalization. In Proceedings of the IEEE International Conference on Computer Vision (ICCV) . [Cited on page 27.]

Li, Y., Yang, J., Song, Y., Cao, L., Luo, J., and Li, L.-J. (2017b). Learning from noisy labels with distillation. In Proceedings of the IEEE international conference on computer vision , pages 1910-1918. [Cited on page 32.]

Liang, J., Hu, D., and Feng, J. (2020). Do we really need to access the source data? Source hypothesis transfer for unsupervised domain adaptation. In International Conference on Machine Learning (ICML) , pages 6028-6039. [Cited on page 2.]

Makar, M., Packer, B., Moldovan, D., Blalock, D., Halpern, Y., and D'Amour, A. (2022). Causally motivated shortcut removal using auxiliary labels. In International Conference on Artificial Intelligence and Statistics , pages 739-766. PMLR. [Cited on pages 2, 8, and 29.]

Mansour, Y., Mohri, M., and Rostamizadeh, A. (2008). Domain adaptation with multiple sources. Advances in neural information processing systems , 21. [Cited on page 32.]

Muandet, K., Balduzzi, D., and Schölkopf, B. (2013). Domain generalization via invariant feature representation. In International Conference on Machine Learning , pages 10-18. [Cited on page 3.]

Nagarajan, V., Andreassen, A., and Neyshabur, B. (2021). Understanding the failure modes of out-of-distribution generalization. In International Conference on Learning Representations . [Cited on page 3.]

Natarajan, N., Dhillon, I. S., Ravikumar, P. K., and Tewari, A. (2013). Learning with noisy labels. Advances in neural information processing systems , 26. [Cited on pages 6, 19, and 32.]

Peters, J., Bühlmann, P., and Meinshausen, N. (2016). Causal inference by using invariant prediction: identification and confidence intervals. Journal of the Royal Statistical Society. Series B (Statistical Methodology) , pages 947-1012. [Cited on pages 1, 2, and 3.]

Pezeshki, M., Kaba, O., Bengio, Y., Courville, A. C., Precup, D., and Lajoie, G. (2021). Gradient starvation: A learning proclivity in neural networks. Advances in Neural Information Processing Systems , 34:1256-1272. [Cited on page 29.]

Puli, A. M., Zhang, L. H., Oermann, E. K., and Ranganath, R. (2022). Out-of-distribution generalization in the presence of nuisance-induced spurious correlations. In International Conference on Learning Representations . [Cited on pages 3, 8, and 29.]

Rame, A., Dancette, C., and Cord, M. (2022). Fishr: Invariant gradient variances for out-ofdistribution generalization. In International Conference on Machine Learning , pages 18347-18377. [Cited on pages 10 and 29.]

Rojas-Carulla, M., Schölkopf, B., Turner, R., and Peters, J. (2018). Invariant models for causal transfer learning. The Journal of Machine Learning Research , 19(1):1309-1342. [Cited on pages 3, 5, 10, 25, and 26.]

Rosenfeld, E., Ravikumar, P., and Risteski, A. (2022). Domain-adjusted regression or: ERM may already learn features sufficient for out-of-distribution generalization. arXiv preprint arXiv:2202.06856 . [Cited on page 3.]

Rothenhäusler, D., Meinshausen, N., Bühlmann, P., and Peters, J. (2021). Anchor regression: Heterogeneous data meet causality. Journal of the Royal Statistical Society: Series B (Statistical Methodology) , 83(2):215-246. [Cited on page 2.]

Rusak, E., Schneider, S., Pachitariu, G., Eck, L., Gehler, P. V ., Bringmann, O., Brendel, W., and Bethge, M. (2022). If your data distribution shifts, use self-learning. Transactions on Machine Learning Research . [Cited on pages 2 and 6.]

Sagawa, S., Koh, P. W., Hashimoto, T. B., and Liang, P. (2019). Distributionally robust neural networks. In International Conference on Learning Representations . [Cited on page 29.]

Schapire, R. E. (1990). The strength of weak learnability. Machine Learning , 5:197-227. [Cited on page 32.]

Schölkopf, B. (2022). Causality for machine learning. In Probabilistic and Causal Inference: The Works of Judea Pearl , pages 765-804. Association for Computing Machinery. [Cited on pages 2 and 26.]

Scott, C., Blanchard, G., and Handy, G. (2013). Classification with asymmetric label noise: Consistency and maximal denoising. In Conference on learning theory , pages 489-511. PMLR. [Cited on page 32.]

Shi, Y., Seely, J., Torr, P., N, S., Hannun, A., Usunier, N., and Synnaeve, G. (2022a). Gradient matching for domain generalization. In International Conference on Learning Representations . [Cited on page 29.]

Shi, Y., Seely, J., Torr, P., Siddharth, N., Hannun, A., Usunier, N., and Synnaeve, G. (2022b). Gradient matching for domain generalization. In International Conference on Learning Representations . [Cited on pages 3, 8, 10, and 29.]

Silva Filho, T., Song, H., Perello-Nieto, M., Santos-Rodriguez, R., Kull, M., and Flach, P. (2023). Classifier calibration: a survey on how to assess and improve predicted class probabilities. Machine Learning , pages 1-50. [Cited on page 10.]

Song, H., Kim, M., Park, D., Shin, Y., and Lee, J.-G. (2022). Learning from noisy labels with deep neural networks: A survey. IEEE Transactions on Neural Networks and Learning Systems . [Cited on page 32.]

Sugiyama, M. and Kawanabe, M. (2012). Machine learning in non-stationary environments: Introduction to covariate shift adaptation . MIT press. [Cited on page 26.]

Sugiyama, M., Krauledat, M., and Müller, K.-R. (2007). Covariate shift adaptation by importance weighted cross validation. Journal of Machine Learning Research , 8(5). [Cited on page 26.]

Sun, Q., Murphy, K., Ebrahimi, S., and D'Amour, A. (2022). Beyond invariance: Test-time labelshift adaptation for distributions with" spurious" correlations. arXiv preprint arXiv:2211.15646 . [Cited on page 2.]

Tanaka, D., Ikami, D., Yamasaki, T., and Aizawa, K. (2018). Joint optimization framework for learning with noisy labels. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition , pages 5552-5560. [Cited on page 32.]

Vapnik, V. (1991). Principles of risk minimization for learning theory. Advances in Neural Information Processing Systems , 4. [Cited on pages 3 and 26.]

Vapnik, V. N. (1998). Statistical Learning Theory . Wiley, New York, NY. [Cited on page 3.]

Veitch, V., D'Amour, A., Yadlowsky, S., and Eisenstein, J. (2021). Counterfactual invariance to spurious correlations: Why and how to pass stress tests. In Advances in Neural Information Processing Systems . [Cited on pages 2, 8, and 29.]

von Kügelgen, J., Mey, A., and Loog, M. (2019). Semi-generative modelling: Covariate-shift adaptation with cause and effect features. In The 22nd International Conference on Artificial Intelligence and Statistics , pages 1361-1369. PMLR. [Cited on pages 5, 10, 25, and 26.]

von Kügelgen, J., Mey, A., Loog, M., and Schölkopf, B. (2020). Semi-supervised learning, causality, and the conditional cluster assumption. In Conference on Uncertainty in Artificial Intelligence , pages 1-10. PMLR. [Cited on pages 5 and 26.]

Wald, Y., Feder, A., Greenfeld, D., and Shalit, U. (2021). On calibration and out-of-domain generalization. Advances in neural information processing systems , 34:2215-2227. [Cited on pages 3, 10, and 29.]

Wang, D., Shelhamer, E., Liu, S., Olshausen, B., and Darrell, T. (2021a). Tent: Fully test-time adaptation by entropy minimization. In International Conference on Learning Representations . [Cited on page 2.]

Wang, D.-B., Feng, L., and Zhang, M.-L. (2021b). Rethinking calibration of deep neural networks: Do not be afraid of overconfidence. Advances in Neural Information Processing Systems , 34:11809-11820. [Cited on page 10.]

Zech, J. R., Badgeley, M. A., Liu, M., Costa, A. B., Titano, J. J., and Oermann, E. K. (2018). Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: a cross-sectional study. PLoS Medicine , 15(11). [Cited on page 3.]

Zhang, J., Lopez-Paz, D., and Bottou, L. (2022). Rich feature construction for the optimizationgeneralization dilemma. In International Conference on Machine Learning . [Cited on pages 3 and 31.]

Zhao, H., Des Combes, R. T., Zhang, K., and Gordon, G. (2019). On learning invariant representations for domain adaptation. In International Conference on Machine Learning , pages 7523-7532. PMLR. [Cited on page 32.]

Zhao, H., Zhang, S., Wu, G., Moura, J. M., Costeira, J. P., and Gordon, G. J. (2018). Adversarial multiple source domain adaptation. Advances in Neural Information Processing Systems , 31. [Cited on page 32.]

Zheng, J. and Makar, M. (2022). Causally motivated multi-shortcut identification & removal. Advances in Neural Information Processing Systems . [Cited on pages 2, 8, and 29.]

Appendices

Table of Contents

A Proof and Further Discussion of Theorem 4.4

A.1 Proof of Theorem 4.4

In this section, we prove our main results regarding the marginal generalization problem presented in Section 4, namely Thm. 4.4. For the reader's convenience, we restate Thm. 4.4 here:

Theorem 4.4 (Marginal generalization with for binary labels and complementary features) . Consider three random variables XS , XU , and Y , where

Y is binary ( { 0, 1 } -valued),

XS and XU are complementary features for Y (i.e., XS ⊥ ⊥ XU | Y ), and

XS is informative of Y ( XS ̸ ⊥ ⊥ Y ).

Then, the joint distribution of ( XS , XU , Y ) can be written in terms of the joint distributions of ( XS , Y ) and ( XS , XU ) . Specifically, if ̂ Y | XS ∼ Bernoulli ( Pr [ Y = 1 | XS ]) is pseudo-label and

are the conditional probabilities that ̂ Y and Y agree, given Y = 0 and Y = 1 , respectively, then,

ϵ 0 + ϵ 1 > 1 ,

Pr [ Y = 1 | XU ] = Pr [ ̂ Y = 1 | XU ] + ϵ 0 -1 + -1 , and

Before proving Thm. 4.4, we provide some examples demonstrating that the complementarity and informativeness assumptions in Thm. 4.4 cannot be dropped.

Example A.1. Suppose XS and XU have independent Bernoulli ( 1/2 ) distributions. Then, XS is informative of both of the binary variables Y 1 = XSXU and Y 2 = XS ( 1 -XU ) and both have identical conditional distributions given XS , but Y 1 and Y 2 have different conditional distributions given XU :

̸

Thus, the complementarity condition cannot be omitted.

On the other hand, XS and XU are complementary for both Y 3 = XU and an independent Y 4 ∼ Bernoulli ( 1/2 ) and both Y 3 and Y 4 both have identical conditional distributions given XS , but Y 1 and Y 2 have different conditional distributions given XU :

̸

Thus, the informativeness condition cannot be omitted.

Before proving Thm. 4.4, we prove Lemma 4.5, which allows us to safely divide by the quantity ϵ 0 + ϵ 1 -1 in the formula for Pr [ Y = 1 | XU ] , under the condition that XS is informative of Y .

Lemma 4.5. In the setting of Thm. 4.4, let ϵ 0 and ϵ 1 be the class-wise pseudo-label accuracies defined in as in Eq. (A.1) . Then, ϵ 0 + ϵ 1 = 1 if and only if XS and Y are independent.

Note that the entire result also holds, with almost identical proof, in the multi-environment setting of Sections 3 and 5, conditioned on a particular environment E .

Proof. We first prove the forward implication. Suppose ϵ 0 + ϵ 1 = 1 . If Pr [ Y = 1 ] ∈ { 0, 1 } , then XS and Y are trivially independent, so we may assume Pr [ Y = 1 ] ∈ ( 0, 1 ) . Then,

Since Y is binary and Pr [ Y = 1 ] ∈ ( 0, 1 ) , it follows that E [ ̂ Y ] = E [ ̂ Y | Y = 0 ] = E [ ̂ Y | Y = 1 ] ; i.e., E [ ̂ Y | Y ] ⊥ ⊥ Y . Since ̂ Y is binary, its distribution is specified entirely by its mean, and so ̂ Y ⊥ ⊥ Y . It follows that the covariance between ̂ Y and Y is 0 :

where the final equality holds because ̂ Y and Y have identical conditional distributions given XS . Since the L 2 norm of a random variable is 0 if and only if the variable is 0 almost surely, it follows that, PXS -almost surely,

so that E [ Y | XS ] ⊥ ⊥ XS . Since Y is binary, its distribution is specified entirely by its mean, and so Y ⊥ ⊥ XS , proving the forward implication.

To prove the reverse implication, suppose XS and Y are independent. Then ̂ Y and Y are also independent. Hence, so that ϵ 0 + ϵ 1 = 1 .

We now use Lemma 4.5 to prove Thm. 4.4:

Proof. To begin, note that ̂ Y has the same conditional distribution given XS as Y (i.e., P ̂ Y | XS = P Y | XS and that ̂ Y is conditionally independent of Y given XS ( ̂ Y ⊥ ⊥ Y | XS ). Then, since Pr [ ̂ Y = 1 ] = E [ Pr [ Y = 1 | XS ]] = Pr [ Y = 1 ] , (A.2)

we have

entirely in terms of the conditional distribution P Y | XS and the marginal distribution PXS . Similarly, ϵ 0 can be written as ϵ 0 = E X S [ ( Pr [ Y = 0 | XS ]) 2 ] E X S [ Pr [ Y = 0 | XS ]] . Meanwhile, by the law of total expectation, and the assumption that XS (and hence ̂ Y ) is conditionally independent of XU given Y , the conditional distribution P ̂ Y | XU of ̂ Y given XU can be written as

̸

By Lemma 4.5, the assumption XS ̸ ⊥ ⊥ Y implies ϵ 0 + ϵ 1 = 1 . Hence, re-arranging the above equality gives us the conditional distribution P Y | XU of Y given XU purely in terms of the conditional P Y | XS and PXS , XU :

It remains now to write the conditional distribution P Y | XS , XU in terms of the conditional distributions P Y | XS and P Y | XU and the marginal PY . Note that

It follows that the logit of Pr [ Y = 1 | XS , XU ] can be written as the sum of a term depending only on XS , a term depending only on XU , and a constant term:

Since the sigmoid σ is the inverse of logit ,

which, by Eq. (4.3), can be written in terms of the conditional distribution P Y | XS and the joint distribution PXS , XU .

A.2 Further discussion of Theorem 4.4

Connections to learning from noisy labels. Thm. 4.4 leverages two theoretical insights about the special structure of pseudo-labels that complement results in the literature on learning from noisy labels. First, Blanchard et al. [7] showed that learning from noisy labels is possible if and only if the total noise level is below the critical threshold ϵ 0 + ϵ 1 > 1 ; in the case of learning from pseudo-labels, we show (see Lemma 4.5 in Appendix A.1) that this is satisfied if and only if XS is informative of Y (i.e., Y ̸ ⊥ ⊥ XS ). Second, methods for learning under label noise commonly assume knowledge of ϵ 0 and ϵ 1 [44], which may be unrealistic in applications where we have absolutely no true (i.e., test-domain) labels; however, for pseudo-labels sampled from a known conditional probability distribution P Y | XS , one can express these noise levels in terms of P Y | XS and PXS and thereby estimate them without any true labels , as on line 3 of Alg. 1.

Possible applications of Thm. 4.4 beyond domain adaptation The reason we wrote Thm. 4.4 in the more general setting of the marginal problem rather than in the specific context of domain adaptation is that we envision possible applications to a number of problems besides domain adaptation. For example, suppose that, after learning a calibrated machine learning model M 1 using a feature XS , we observe an additional feature XU . In the case that XS and XU are complementary, Thm. 4.4 justifies using the student-teacher paradigm [11, 2, 27] to train a model for predicting Y from XU (or from ( XS , XU ) jointly) based on predictions from M 1 . This could be useful if we don't have access to labeled pairs ( XU , Y ) , or if retraining a model using XS would require substantial computational resources or access to sensitive or private data. Exploring such approaches could be a fruitful direction for future work

B Proof of Theorem 4.6

This appendix provides a proof of Thm. 4.6, which provides conditions under which our proposed domain adaptation procedure (Alg. 1) is consistent.

We state a formal version of Thm. 4.6:

Theorem 4.6 (Consistency of the bias-corrected classifier) . Assume

XS is stable,

XS and XU are complementary, and

XS is informative of Y (i.e., XS ̸ ⊥ ⊥ Y ).

Let ̂ η n : X S × XU → [ 0, 1 ] given by

denote the bias-corrected regression function estimate proposed in Alg. 1, and let ̂ hn : X S ×X U → { 0, 1 } given by

denote the corresponding hard classifier. Let η U : X U → [ 0, 1 ] , given by η U ( xU ) = Pr [ Y = 1 | XU = xU , E = 1 ] for all xU ∈ X U , denote the true regression function over XU , and let ̂ η U , n denote its estimate as assumed in Line 4 of Alg. 1. Then, as n → ∞ ,

(a) if, for PXU -almost all xU ∈ X U , ̂ η U , n ( xU )) → η U ( xU ) in probability, then ̂ η n and ̂ hn are weakly consistent (i.e., ̂ η n ( xS , xU ) → η ( xS , xU ) PXS , XU -almost surely and R ( ̂ hn ) → R ( h ∗ ) in probability).

(b) if, for PXU -almost all xU ∈ X U , ̂ η U , n ( xU )) → η U ( xU ) almost surely, then ̂ η n and ̂ hn are strongly consistent (i.e., ̂ η n ( xS , xU ) → η ( xS , xU ) PXS , XU -almost surely and R ( ̂ hn ) → R ( h ∗ ) a.s.).

Before proving Thm. 4.6, we provide a few technical lemmas. The first shows that almost-everywhere convergence of regression functions implies convergence of the corresponding classifiers in classification risk:

Lemma B.1. Consider a sequence of regression functions η , η 1 , η 2, ... : X → [ 0, 1 ] . Let h , h 1 , h 2, ... : X → { 0, 1 } denote the corresponding classifiers

(a) If η n ( x ) → η ( x ) for PX -almost all x ∈ X in probability, then R ( hn ) → R ( h ∗ ) in probability.

(b) If η n ( x ) → η ( x ) for PX -almost all x ∈ X almost surely as n → ∞ , then R ( hn ) → R ( h ) almost surely.

̸

̸

We utilize this observation to prove both (a) and (b).

Proof of (a) Let δ > 0 . By Inequality (B.1) and partitioning X based on whether | 2 η ( X ) -1 | ≤ δ /2 ,

̸

Hence,

̸

̸

Proof of (b) For any x ∈ X with η ( x ) = 1/2 , if η n ( x ) → η ( x ) then 1 {| η n ( x ) -η ( x ) | ≥ | η ( x ) -1/2 |} → 0 . Hence, by Inequality (B.1), the dominated convergence theorem (with | 2 η ( x ) -1 | 1 {| η n ( x ) -η ( x ) | ≥ | η ( x ) -1/2 |} ≤ 1 ), and the assumption that η n ( x ) → η ( x ) for PX -almost all x ∈ X almost surely,

̸

Our next lemma concerns an edge case in which the features XS and XU provide perfect but contradictory information about Y , leading to Equation (4.4) being ill-defined. We show that this can happen only with probability 0 over ( XS , XU ) ∼ PXS , XU can thus be safely ignored:

Lemma B.2. Consider two predictors XS and XY of a binary label Y . Then,

Proof. Suppose, for sake of contradiction, that the event

has positive probability. Then, the conditional expectation E [ Y | A ] is well-defined, giving the contradiction

The case E [ Y | XS ] = 0 and E [ Y | XU ] = 1 is similar.

We now utilize Lemmas B.1 and B.2 to prove Thm. 4.6.

Proof. By Lemma B.1, it suffices to prove that ̂ η ( xS , xU ) → η ( xS , xU ) , for PXS , XU -almost all ( xS , xU ) ∈ X S ×X U , in probability (to prove (a)) and almost surely (to prove (b)).

Finite case We first consider the case when both Pr [ Y | XS = xS ] , Pr [ Y | XU = xU ] ∈ ( 0, 1 ) , so that f S ( xS ) and logit ( ˜ η ( xU )+ ϵ 0 -1 ϵ 0 + ϵ 1 -1 ) are both finite. Since

where the sigmoid σ : R → [ 0, 1 ] is continuous, by the continuous mapping theorem and the assumption that ̂ η U ,1 ( xU ) → ˜ η ( xU ) , to prove both of these, it suffices to show:

(i) ̂ ϵ 0 → ϵ 0 and ̂ ϵ 1 → ϵ 1 almost surely as n → ∞ .

(ii) ̂ β 1, n → β 1 ∈ ( -∞ , ∞ ) almost surely as n → ∞ .

(iii) The mapping ( a , b , c ) ↦→ logit ( a + b -1 b + c -1 ) is continuous at ( ˜ η ( xU ) , ϵ 0, ϵ 1 ) .

We now prove each of these in turn.

Proof of (i) Since ̂ Yi ⊥ ⊥ Yi | XS and 0 < Pr [ ̂ Y = 1 ] , by the strong law of large numbers and the continuous mapping theorem,

almost surely as n → ∞ . Similarly, since Pr [ ̂ Y = 0 ] = 1 -Pr [ ̂ Y = 1 ] > 0 , ̂ ϵ 0 → ϵ 0 almost surely.

Proof of (ii) Recall that

By the strong law of large numbers, 1 n ∑ n i = 1 ̂ Yi → Pr [ ̂ Y = 1 | E = 1 ] = Pr [ Y = 1 | E = 1 ] . Since we assumed Pr [ Y = 1 | E = 1 ] ∈ ( 0, 1 ) , it follows that the mapping a ↦→ logit ( a ) is continuous at a = Pr [ Y = 1 | E = 1 ] . Hence, by the continuous mapping theorem, ̂ β 1, n → logit ( Pr [ Y = 1 | E = 1 ]) = β 1 almost surely.

Proof of (iii) Since the logit function is continuous on the open interval ( 0, 1 ) and we assumed ϵ 0 + ϵ 1 > 1 , it suffices to show that 0 < ˜ η ( xU ) + ϵ 0 -1 < ϵ 0 + ϵ 1 -1 . Since, according to Thm. 4.4, this holds as long as 0 < η ∗ ( xU ) < 1 , as we assumed for PXU -almost all xU ∈ X U .

Infinite case We now address the case where either Pr [ Y | XS = xS ] ∈ { 0, 1 } or Pr [ Y | XU = xU ] ∈ { 0, 1 } . By Lemma B.2, only one of these can happen at once, PXS , XU -almost surely. Hence, since lim n → ∞ ̂ β 1, n is also finite almost surely, if Pr [ Y | XS = xS ] ∈ { 0, 1 } , then ̂ η ( xS , xU ) = σ ( logit ( Pr [ Y | XS = xS ])) = η ( xS , xU ) , while, if Pr [ Y | XU = xU ] ∈ { 0, 1 } , then ̂ η ( xS , xU ) → σ ( logit ( Pr [ Y | XU = xU ])) = η ( xS , xU ) , in probability or almost surely, as appropriate.

C Multiclass Case

In the main paper, to simplify notation, we presented our unsupervised test-domain adaptation method in the case of binary labels Y . However, in many cases, including several of our experiments in Section 6, the label Y can take more than 2 distinct values. Hence, in this section, we show how to generalize our method to the multiclass setting and then present the exact procedure (Alg. 2) used in our multiclass experiments in Section 6.

Suppose we have K ≥ 2 classes. We 'one-hot encode' these classes, so that Y takes values in the set

Let ϵ ∈ [ 0, 1 ] Y×Y with

denote the class-conditional confusion matrix of the pseudo-labels. Then, we have

When ϵ is non-singular, this has the unique solution E [ Y | XU ] = ϵ -1 E [ ̂ Y | XU ] , giving a multiclass equivalent of Eq. (4.3) in Thm. 4.4. In practice, however, it is numerically more stable to estimate E [ Y | XU ] by the least-squares solution

which is what we will do in Algorithm 2. To estimate ϵ without observing the label Y in the test domain, note that

This suggests the estimate

of each ϵ y , y ′ , or, in matrix notation,

where Normalize ( X ) scales each column of X to sum to 1 . This gives us a multiclass equivalent of Line 3 in Alg. 1.

̸

The multiclass versions of Eq. (4.4) and Line 6 of Alg. 1 are slightly less straightforward. Specifically, whereas, in the binary case, we used the fact that Pr [ XS , XU | Y = 1 ] = Pr [ XS , XU | Y = 0 ] = Pr [ XS | Y = 0 ] Pr [ XU | Y = 0 ] = Pr [ XS | Y = 1 ] Pr [ XU | Y = 1 ] (by complementarity), in the multiclass case, we do not have Pr [ XS , XU | Y = 1 ] = Pr [ XS | Y = 1 ] Pr [ XU | Y = 1 ] . However, following similar reasoning as in the proof of Thm. 4.4, we have

̸

̸

̸

̸

Hence,

̸

̸

̸

̸

̸

̸

̸

̸

̸

̸

for Q ∈ R Y defined by

We can estimate Qy by

In matrix notation, this is

In particular, applying the sigmoid function to each side, we have

where ◦ denotes element-wise multiplication. It follows that, for p ∈ ∆ Y (we will use py = Pr [ Y = y ] ), we can use the multiclass combination function C : ∆ Y × ∆ Y → ∆ Y with

where the multiplication and division are performed element-wise and Normalize ( x ) = x ∥ x ∥ 1 , to generalize Eq. (4.5). Putting these derivations together gives us our multiclass version of Alg. 1, presented in Alg. 2, where ∆ Y = { z ∈ [ 0, 1 ] K : ∑ y ∈Y zy = 1 } denotes the standard probability simplex over Y .

Algorithm 2: Multiclass bias-corrected adaptation procedure.

Input: Calibrated stable classifier fS : X → ∆ Y with fS , y ( xS ) = Pr [ Y = y | XS = xS ] , n unlabeled samples { ( XS , i , XU , i ) } n i = 1

Output: Joint classifier ̂ f : X S ×X U → ∆ Y estimating Pr [ Y = y | XS = xS , XU = xU ]

1 Compute soft pseudo-labels { ̂ Yi } n i = 1 with ̂ Yi = f S ( XS , i )

̂ 3 Estimate class-conditional pseudo-label confusion matrix ̂ ϵ ← f ⊺ S ( XS ) Normalize ( f ⊺ S ( XS ))

, i = 1 // ≈ Pr [ ̂ Y = y | XU ]

2 Compute soft class counts n = ∑ n i = 1 ̂ Yi

4 Fit unstable classifier ˜ fU ( xU ) to pseudo-labelled data { ( XU i , ̂ Yi ) } n

5 Bias-correction ̂ fU ( xU ) ↦→ arg min p ∈ ∆ Y ∥ ϵ p -˜ fU ( xU ) ∥ 2 // ≈ Pr [ Y = y | XU ]

6 return ̂ f ( xS , xU ) ↦→ C ̂ n / n ( f S ( xS ) , ̂ fU ( xU )) // Eq. (C.1), ≈ Pr [ Y = y | XS , XU ]

D Supplementary Results

D.1 Trivial solution to joint-risk minimization

In Prop. D.1 below, we assume that the stable f S ( X ) and unstable fU ( X ) predictors output logits . In contrast, throughout the rest of the paper, we assume that f S ( X ) and fU ( X ) output probabilities in [ 0, 1 ] .

Proposition D.1. Suppose ̂ Y | f S ( X ) ∼ Bernoulli ( σ ( f S ( X ))) , such that ̂ Y ⊥ ⊥ fU ( X ) | f S ( X )

where ℓ ( x , y ) = -x log y -( 1 -x ) log ( 1 -y ) denotes the cross-entropy loss.

. Then,

Proof. Suppose ̂ Y | f S ( X ) ∼ Bernoulli ( σ ( f S ( X ))) , such that ̂ Y ⊥ ⊥ fU ( X ) | f S ( X ) . Then,

Since the cross-entropy loss is differentiable and convex, any fU ( X ) satisfying 0 = d dfU ( X ) E [ ℓ ( ̂ Y , f S ( X ) + fU ( X ))] is a minimizer. Indeed, under the mild assumption that the expectation and derivative commute, for fU ( X ) = 0 ,

D.2 Causal perspectives

The stability, complementarity, and informativeness assumptions in Thm. 4.4 can be interpreted as constraints on the causal relationships between the variables XS , XU , Y , and E . We conclude this section with a result with a characterization of causal, directed acyclic graphs (DAGs) that are consistent with these assumptions. In particular, this result shows that our assumptions are satisfied in the 'anti-causal' and 'cause-effect' settings assumed in prior work [49, 68, 31], as well as work assuming only covariate shift (i.e., changes in the distribution of X without changes in the conditional P Y | X ).

E

XS

,

C

XS

,

E

XU

Y

XS

,

S

Proposition D.2 (Possible Causal DAGs) . Consider an environment variable E , two covariates XU and XS , and a label Y . Assume there are no other hidden confounders (i.e., causal sufficiency). First, assume:

E is a root (i.e., none of XU , XS , and Y is an ancestor of E ).

XS is informative of Y (i.e., XS ̸ ⊥ ⊥ Y | E ).

XS and XU are complementary predictors of Y ; i.e., XS ⊥ ⊥ XU | ( Y , E ) .

XS is stable (i.e., E ⊥ ⊥ Y | XS ).

These are the four structural assumptions under which Theorems 4.4 and 4.6 show that the SFB algorithm learns the conditional distribution P Y | XS , XU in the test domain. Additionally, suppose

XU is unstable (i.e., E ̸ ⊥ ⊥ Y | XU ), This is the case in which empirical risk minimization [ERM; 65] may suffer bias due to distribution shift, and hence when SFB may outperform ERM.

XU contains some information about Y that is not included in XS (i.e., XU ̸ ⊥ ⊥ Y | XS ). This is information we expect invariant risk minimization [IRM; 1] is unable to learn, and hence when we expect SFB to outperform IRM.

Then, XU consists of causal descendants ('effects') of Y , while three types of stable features are possible:

causal ancestors XS , C of Y ,

causal descendants XS , E of Y that are not also descendants of E ,

causal spouses XS , S of Y (i.e., causal ancestors of XS , E ).

Notable special cases of the DAG in Figure 3 include:

the 'cause-effect' settings, studied by Rojas-Carulla et al. [49], von Kügelgen et al. [68, 69], where XS is a cause of Y , XU is an effect of Y , and E may affect both XS and XU but may affect Y only indirectly through XS . Note that this generalizes the commonly used 'covariate shift' assumption, as not only the covariate distribution PXS , XU but also the conditional distribution P Y | XU can change between environments.

the 'anti-causal' setting, studied by Jiang and Veitch [31], where XS and XU are both effects of Y , but XS is unaffected by E .

the widely studied 'covariate shift' setting [62, 23, 6, 61], which corresponds (see Sections 3 and 5 of Schölkopf [55]) to a causal factorization P ( X , Y ) = P ( X ) P ( Y | X ) (i.e., in which the only stable components XS are causes XS , C ) of Y or unconditionally independent (e.g., causal spouses XS , S )) of Y .

However, this model is more general than these special cases. Also, for sake of simplicity, we assumed causal sufficiency here; however, in the presence of unobserved confounders, other types of stable features are also possible; for example, if we consider the possibility of unobserved confounders U influencing Y that are independent of E (i.e., invariant across domains), then our method can also utilize stable features that are descendants of U (i.e., 'siblings' of Y ).

E Datasets

In our experiments, we consider five datasets: two (synthetic) numerical datasets and three image datasets. We now describe each dataset.

Synthetic: Anti-causal (AC). We consider an anti-causal synthetic dataset based on that of Jiang and Veitch [31, §6.1] where data is generated according to the following structural equations:

β

e

XS

Y

XU

where the input X = ( XS , XU ) and Rad ( β ) denotes a Rademacher random variable that is -1 with probability 1 -β and + 1 with probability β . Following Jiang and Veitch [31, §6.1], we create two training domains with β e ∈ { 0.95, 0.7 } , one validation domain with β e = 0.6 and one test domain with β e = 0.1 .

Synthetic: Cause-effect with a direct XS -XU dependence (CE-DD). We also consider a synthetic cause-effect dataset in which there is a direct dependence between XS and XU . In particular, following Jiang and Veitch [31, App. B], data is generated according to the following structural equations:

XU ← ( ( Y , ( β e )) , XS ) ,

β

e

XS

Y

XU

where the input X = ( XS , XU ) and Bern ( β ) denotes a Bernoulli random variable that is 1 with probability β and 0 with probability 1 -β . Note that XS ̸ ⊥ ⊥ XU | Y , since XS directly influences XU . Following Jiang and Veitch [31, App. B], we create two training domains with β e ∈ { 0.95, 0.8 } , one validation domain with β e = 0.2 , and one test domain with β e = 0.1 .

ColorMNIST. We next consider the ColorMNIST dataset [1]. This transforms the original MNIST dataset into a binary classification task (digit in 0-4 or 5-9) and then: (i) flips the label with probability 0.25, meaning that, across all 3 domains, digit shape correctly determines the label with probability 0.75; and (ii) colorizes the digit such that digit color (red or green) is a more informative but spurious feature (see Fig. 4).

PACS. We next consider the PACS dataset [37]-a 7-class image-classification dataset consisting of 4 domains: photos (P), art (A), cartoons (C) and sketches (S), with examples shown in Fig. 4. Model performances are reported for each domain after training on the other 3 domains.

Camelyon17. Finally, in the additional experiments of App. F.2, we consider the Camelyon17 [3] dataset from the WILDS benchmark [33]: a medical dataset with histopathology images from 5 hospitals which use different staining and imaging techniques (see Fig. 4). The goal is to determine whether or not a given image contains tumor tissue, making it a binary classification task across 5 domains (3 training, 1 validation, 1 test).

Dataset

+90%

+80%

%06-

3

ColorMNIST

(degreeofcorrelationbetweencolorandlabel)

Art

Cartoon

Photo

Sketch

PACS

d =Hospital 1

d =Hospital 2

d =Hospital 3

d = Hospital 4

d =Hospital5

Camelyon17

F Further Experiments

This appendix provides further experiments which supplement those in the main text. In particular, it provides: (i) an ablation on the ColorMNIST dataset showing the effects of bias correction, posthoc calibration and multiple rounds of pseudo-labelling on SFB's performance (F.1.1); (ii) the

performance of SFB on the ColorMNIST dataset when using different stability penalties (F.1.2); and (iii) results on a real-world medical dataset, Camelyon17 [3], where we find that all methods perform similarly when properly tuned (F.2).

F.1 ColorMNIST

We now provide ablations on the ColorMNIST dataset to illustrate the effectiveness of the different components of SFB. In particular, we focus on bias correction and calibration, while also showing how multiple rounds of pseudo-labeling can improve performance in practice.

F.1.1 Ablations

Bias correction. To adapt the unstable classifier in the test domain, SFB employs the bias-corrected adaptation algorithm of Alg. 1 (or Alg. 2 for the multi-class case) which corrects for biases caused by possible disagreements between the stable-predictor pseudo-labels ̂ Y and the true label Y . In this (sub)section, we investigate the performance of SFB with and without bias correction (BC).

Calibration. As discussed in § 4.2, correctly combining the stable and unstable predictions postadaptation requires them to be properly calibrated. In particular, it requires the stable predictor f S to be calibrated with respect to the true labels Y and the unstable predictor fU to be calibrated with respect to the pseudo-labels ̂ Y . In this (sub)section, we investigate the performance of SFB with and without post-hoc calibration (in particular, simple temperature scaling [25]). More specifically, we investigate the effect of calibrating the stable predictor (CS) and calibrating the unstable predictor (CU).

Multiple rounds of pseudo-labeling. While SFB learns the optimal unstable classifier h e U in the test domain given enough unlabelled data , § 4.1 discussed how more accurate pseudo-labels ̂ Y improve the sample efficiency of SFB. In particular, in a restricted-sample setting, more accurate pseudo-labels result in an unstable classifier h e U which better harnesses XU in the test domain. With this in mind, note that, after adapting, we expect the joint predictions of SFB to be more accurate than its stable-only predictions. This raises the question: can we use these improved predictions to form more accurate pseudo-labels, and, in turn, an unstable classifier h e U that leads to even better performance? Furthermore, can we repeat this process, using multiple rounds of pseudo-labelling to refine our pseudo-labels and ultimately h e U ? While this multi-round approach loses the asymptotic guarantees of § 4.2, we found it to work quite well in practice. In this (sub)section, we thus investigate the performance of SFB with and without multiple rounds of pseudo-labeling (PL rounds).

Results. Table 4 reports the ablations of SFB on ColorMNIST . Here we see that: (i) bias correction significantly boosts performance (+BC); (ii) calibrating the stable predictor also boosts performance without (+CS) and with (+BC+CS) bias correction, with the latter leading to the best performance; (iii) calibrating the unstable predictor (with respect to the pseudo-labels) slightly hurts performance without (+CU) and with (+BC+CS+CU) bias correction and stable-predictor calibration; (iv) multiple rounds of pseudo-labeling boosts performance, while also reducing the performance variation across random seeds; (v) using bias correction, stable-predictor calibration and 5 rounds of pseudo-labeling results in near-optimal adaptation performance, as indicated by the similar performance of SFB when using true labels Y to adapt h e U (denoted 'SFB GT adpt.' in Table 4).

F.1.2 Different stability penalties

In our experiments of § 6, we used IRM for the stability term of our SFB method, given in Eq. (5.1). However, as discussed in § 5, many other approaches exist for enforcing stability [35, 58, 47, 15, 67, 40, 77], and, in principle, any of these could be used. To illustrate this point, we now evaluate the performance of SFB when using different stability penalties, namely IRM [1], VREx [35], EQRM[15] and CLOvE [70]. For all penalties, we use SFB with bias correction, post-hoc calibration of the stable predictor, and 5 rounds of pseudo-labeling (see the ablation study of App. F.1.1).

F.1.3 Full results

We now provide extended/full results of those provided in the main text. In particular, Table 6 represents an extended version of Table 3 in the main text, comparing against many more baseline methods. In addition, Table 7 provides the full numerical results for all adaptive baseline methods (described in App. G.1), which correspond to the plots of Fig. 2 in the main text.

F.2 Camelyon17

We now provide results on the Camelyon17 [3] dataset. See App. E for a description of the dataset, and App. G.5 for implementation details.

Algorithm

Domain (Color-Label Correlation)

1.0

0.9

0.8

0.7

0.6

0.5

-0.6

-0.7

-0.8

-0.9

-1.0

ERM

97.5

±

0.3

88.5

±

0.4

79.7

±

0.4

70.6

±

0.5

61.4

±

0.7

52.5

±

0.4

43.5

±

0.7

34.7

±

0.7

25.1

±

0.5

16.4

±

0.4

7.6

±

0.6

ERM+T3A

98.1

±

0.2

88.9

±

0.4

79.8

±

0.4

70.4

±

0.5

61.0

±

0.8

51.7

±

0.4

42.3

±

0.7

33.0

±

0.6

23.1

±

0.4

13.8

±

0.5

4.5

±

0.5

ERM+PL (last)

97.6

±

0.2

88.6

±

0.3

79.7

±

0.4

70.6

±

0.5

61.4

±

0.8

52.5

±

0.4

43.4

±

0.7

34.6

±

0.7

25.0

±

0.5

16.2

±

0.3

7.4

±

0.6

ERM+PL (all)

100

.

0

±

0

.

0

90.0

±

0.4

80

.

2

±

0

.

4

70.1

±

0.4

59.9

±

0.8

50.1

±

0.4

40.0

±

0.5

30.1

±

0.6

19.6

±

0.3

9.9

±

0.3

0.0

±

0.1

IRM

70.6

±

2.1

70.3

±

1.9

70.4

±

1.7

70.2

±

1.1

69.9

±

0.7

69

.

9

±

0

.

7

70.1

±

0.5

69.7

±

0.6

69.8

±

1.2

69.6

±

1.6

69.4

±

1.7

IRM+T3A

72.3

±

1.7

71.2

±

1.6

70.7

±

1.6

70.2

±

1.0

69.8

±

0.7

69

.

9

±

0

.

7

70

.

3

±

0

.

6

70.6

±

0.5

71.6

±

1.1

72.4

±

1.7

73.4

±

1.9

IRM+PL (last)

70.8

±

2.2

70.5

±

1.9

70.5

±

1.7

70.2

±

1.1

69.9

±

0.7

69

.

9

±

0

.

6

70.0

±

0.6

69.7

±

0.6

69.9

±

1.2

69.8

±

1.6

69.7

±

1.7

IRM+PL (all)

99.6

±

1.2

89.4

±

1.2

79.5

±

1.3

68.7

±

3.8

63.3

±

4.7

63.5

±

5.3

63.8

±

4.5

67.5

±

2.8

76.4

±

4.2

87.2

±

5.0

98.2

±

3.0

SFB

100

.

0

±

0

.

1

90

.

5

±

0

.

5

79.8

±

0.8

71

.

0

±

1

.

1

70

.

9

±

0

.

3

69.2

±

0.4

68.4

±

1.3

71

.

2

±

0

.

3

79

.

3

±

1

.

2

88

.

7

±

1

.

3

98

.

9

±

1

.

5

Table 2 shows that ERM, IRM and SFB perform similarly on Camelyon17 . In line with [24], we found that a properly-tuned ERM model can be difficult to beat on real-world datasets, particularly when the model is pre-trained on ImageNet and the dataset doesn't contain severe distribution shift. While we conducted this proper tuning for ERM, IRM, and SFB (see App. G.5), doing so for ACTIR was non-trivial. We thus report the result from their paper [31, Table 1], which is likely lower due to sub-optimal hyperparameters. In particular, we found that, for ERM and IRM, using a lower learning rate (1e-5 vs 1e-4) and early stopping (1 vs 25 epochs) improved performance by 20 percentage points, from around 70% [31, Table 1] to around 90% (Table 8 below). It remains to be seen whether or not ACTIR can improve over a properly-tuned ERM model on Camelyon17 .

While it may seem disappointing that SFB does not outperform the simpler methods of IRM and ERM on Camelyon17 , we note that SFB can only be expected to do well when there is some gain in out-of-distribution performance from enforcing stability, e.g., when IRM outperforms ERM. The identical performances of IRM and ERM in Table 8 indicate that, with ImageNet pre-training and proper hyperparameter tuning, this is not the case for Camelyon17 . Finally, despite the similar performances, we note that adapting SFB on Camelyon17 still gives a small performance boost and reduces the variance across random seeds.

G Implementation Details

Below we provide further implementation details for the experiments of this work. Code is available at: https://github.com/cianeastwood/sfb.

G.1 Adaptive baselines

For both the synthetic and CMNIST datasets, we compare against adaptive baseline methods by using pseudo-labeling (PL, [36]) and test-time classifier adjustment (T3A, [30]) on top of both ERM and IRM, choosing all adaptation hyperparameters using leave-one-domain-out cross-validation:

ERM/IRM + PL (last): After training with ERM/IRM, we update the last layer using the model's own pseudo-labels [36].

ERM/IRM + PL (all): After training with ERM/IRM, we update all layers using the model's own pseudo-labels [36].

ERM/IRM + T3A: After training with ERM/IRM, we replace the classifier (final layer) with the template-based classifier of T3A [30]. This means: (i) computing template representations for each class using pseudo-labeled test-domain data; and (ii) classifying each example based on its distance to these templates.

G.2 Synthetic experiments

Following Jiang and Veitch [31], we use a simple three-layer network with 8 units in each hidden layer and the Adam optimizer, choosing hyperparameters using the validation domain.

For SFB, we sweep over λ S in { 0.01, 0.1, 1, 5, 10, 20 } and λ C in { 0.01, 0.1, 1 } . For SFB's unsupervised adaptation, we employ the bias correction of Alg. 1 and calibrate the stable predictor using post-hoc temperature scaling, choosing the temperature to minimize the expected calibration error (ECE, [25]) on the validation domain. In addition, we use the Adam optimizer with an adaptation learning rate of 0.01 , choosing the number of adaptation steps in [ 1, 20 ] (via early stopping) using the validation domain. Finally, we report the mean and standard error over 100 random seeds.

G.3 ColorMNIST experiments

Training details. We follow the setup of Eastwood et al. [15, §6.1] and build on their open-source code 5 . In particular, we use the original MNIST training set to create training and validation sets for each domain, and the original MNIST test set for the test sets of each domain. For all methods, we use a 2-hidden-layer MLP with 390 hidden units, the Adam optimizer, a learning rate of 0.0001 with cosine scheduling, and dropout with p = 0.2 . In addition, we use full batches (size 25000 ), 400 steps for ERM pre-training (which directly corresponds to the delicate penalty 'annealing' or warm-up periods used by penalty-based methods on ColorMNIST [1, 35, 15, 74]), and 600 total steps. We sweep over stability-penalty weights in { 50, 100, 500, 1000, 5000 } for IRM, VREx and SFB and α 's in 1 -{ e -100 , e -250 , e -500 , e -750 , e -1000 } for EQRM. As the stable (shape) and unstable (color) features are conditionally independent given the label, we fix SFB's conditional-independence penalty weight λ C = 0 . As is the standard for ColorMNIST , we use a test-domain validation set to select the best settings (after the total number of steps), and then report the mean and standard error over 10 random seeds on a test-domain test set. As in previous works, the hyperparameter ranges of all methods are selected by peeking at test-domain performance. While far from ideal, this is quite difficult to avoid with ColorMNIST and highlights a core problem with hyperparameter selection in DG-as discussed by many previous works [1, 35, 24, 74, 15].

SFB adaptation details. For SFB's unsupervised adaptation in the test domain, we use a batch size of 2048 and employ the bias correction of Alg. 1. In addition, we calibrate the stable predictor using post-hoc temperature scaling, choosing the temperature to minimize the expected calibration error (ECE, [25]) across the two training domains. Again using the two training domains for hyperparameter selection, we sweep over adaptation learning rates in { 0.1, 0.01 } , choose the best adaptation step in [ 5, 20 ] (via early stopping), and sweep over the number of pseudo-labeling rounds in [ 1, 5 ] . Finally, we report the mean and standard error over 3 random seeds for adaptation.

G.4 PACS experiments

We follow the setup of Jiang and Veitch [31, § 6.4] and build on their open-source code 6 . This means using an ImageNet-pretrained ResNet-18, the Adam optimizer with a learning rate of 10 -4 , and choosing hyperparameters using leave-one-domain-out cross-validation (akin to K-fold crossvalidation, except with domains). In particular, for each held-out test domain, we train 3 models-each time leaving out 1 of the 3 training domains for validation-and then select hyperparameters based on the best average performance across the held-out validation domains. Finally, we use the selected hyperparameters to retrain the model using all 3 training domains.

For SFB, we sweep over λ S in { 0.01, 0.1, 1, 5, 10, 20 } , λ C in { 0.01, 0.1, 1 } , and learning rates in { 10 -4 , 50 -4 } . For SFB's unsupervised adaptation, we employ the multi-class bias correction of Alg. 2 and calibrate the stable predictor using post-hoc temperature scaling, choosing the temperature

to minimize the expected calibration error (ECE, [25]) across the three training domains. In addition, we use the Adam optimizer with an adaptation learning rate of 0.01 , choosing the number of adaptation steps in [ 1, 20 ] (via early stopping) using the training domains. Finally, we report the mean and standard error over 5 random seeds.

G.5 Camelyon17 experiments

We follow the setup of Jiang and Veitch [31, § 6.3] and build on their open-source code 7 . This means using an ImageNet-pretrained ResNet-18, the Adam optimizer, and, following [33], choosing hyperparameters using the validation domain (hospital 4). In contrast to [31], we use a learning rate of 10 -5 for all methods, rather than 10 -4 , and employ early stopping using the validation domain. We found this to significantly improve all methods. E.g., the baselines of ERM and IRM improve by approximately 20 percentage points, jumping from ≈ 70 %to ≈ 90 %.

For SFB, we sweep over λ S in { 0.01, 0.1, 1, 5, 10, 20 } and λ C in { 0.01, 0.1, 1 } . For SFB's unsupervised adaptation, we employ the bias correction of Alg. 1 and calibrate the stable predictor using post-hoc temperature scaling, choosing the temperature to minimize the expected calibration error (ECE, [25]) on the validation domain. In addition, we use the Adam optimizer with an adaptation learning rate of 0.01 , choosing the number of adaptation steps in [ 1, 20 ] (via early stopping) using the validation domain. Finally, we report the mean and standard error over 5 random seeds.

H Further Related Work

Learning with noisy labels. An intermediate goal in our work, namely learning a model to predict Y from XU using pseudo-labels based on XS , is an instance of learning with noisy labels , a widely studied problem [56, 44, 7, 60, 38, 64]. Specifically, under the complementarity assumption ( XS ⊥ ⊥ XU | Y ), the accuracy of the pseudo-labels on each class is independent of XU , placing us in the so-called class-conditional random noise model [56, 44, 7]. As we discuss in Section 4, our theoretical insights about the special structure of pseudo-labels complement existing results on learning under this model. Our bias-correction (Eq. (4.3)) for P Y | XU is also closely related to the 'method of unbiased estimators' [44]. However, rather than correcting the loss used in ERM, our post-hoc bias correction applies to any calibrated classifier. Moreover, our ultimate goal, learning a predictor of Y jointly using XS and XU , is not captured by learning with noisy labels.

Co-training. Our use of stable-feature pseudo-labels to train a classifier based on a disjoint subset of (unstable) features is reminiscent of co-training [10]. Both methods benefit from conditional independence of the two feature subsets given the label to ensure that they provide complementary information. 8 The key difference is that while co-training requires (a small number of) labeled samples from the same distribution as the test data , our method instead uses labeled data from a different distribution (training domains), along with the assumption of a stable feature. Additionally, while co-training iteratively refines two pre-trained classifiers symmetrically based on each other's predictions, our method only trains the unstable classifier, in a single iteration, using the stable classifier's predictions.

Boosting. Our method of building a strong (albeit unstable) classifier using a weak (but stable) one is reminiscent of boosting, in which one ensembles weak classifiers to create a single strong classifier [54] and which inspires the name of our approach, 'stable feature boosting (SFB)'. However, whereas traditional boosting improves weak classifiers by examining how their predictions differ from true labels, our adaptation method utilizes only pseudo-labels and needs no true labels from the test domain. For example, while traditional boosting only refines functions of existing features, SFB can utilize new features that are only available in the test domain.

Learning theory for domain generalization. In addition to often assuming particular kinds of distribution shifts (e.g., covariate shift), existing error bounds for domain generalization often depend on some notion of distance between training and test domains (which does not vanish as more data is collected within domains) [9, 5, 76, 75] or assume that the test domain has a particular structural relationship with the training domains (e.g., is a convex combination of training domains [41]).

In contrast, under the structure of invariant and complementary features, we show that consistent generalization (i.e., with generalization error vanishing as more data is collected within domains) is possible in any test domain. Additionally, whereas these prior works derive uniform convergence bounds (implying good generalization for ERM), our results demonstrate the benefit of an additional bias-correction step after training. We also note that, in much of this literature, 'invariance' refers to invariance of the covariate marginal distribution PX across domains; in contrast, our notion of stable features (Defn. 4.1) refers to invariance of the conditional P Y | X .

I Performance When Complementarity is Violated

Thm. 4.4 justifies the bias correction of Eq. (4.3) under the assumption that stable XS and unstable XU features are complementary, i.e., conditionally independent given the label Y . In this section, we discuss what happens if this assumption is relaxed and provide some intuition for why the bias correction appears to help even when complementarity is violated (as we observed in some of our experiments). In particular, we provide an argument that, in most cases, the bias correction should improve the accuracy of a naive classifier by making it agree more often with the Bayes-optimal classifier. While not a rigorous proof, we believe that this argument provides some insight into SFB's strong performance even when complementarity is violated.

In the absence of complementarity, the quantity Pr [ ̂ Y = 1 | Y = 1, Xu = xU ] no longer reduces to the class-wise accuracy Pr [ ̂ Y = 1 | Y = 1 ] ; thus we write more generally ϵ 1 ( xU ) = Pr [ ̂ Y = 1 | Y = 1, Xu = xU ] , and we write ϵ 1 = E XU [ ϵ 1 ( XU )] = Pr [ ̂ Y = 1 | Y = 1 ] instead of simply ϵ 1 for the accuracy on class 1 . Similarly, we write ϵ 0 ( xU ) = Pr [ ̂ Y = 0 | Y = 0, Xu = xU ] , and we write ϵ 0 = E XU [ ϵ 0 ( XU )] = Pr [ ̂ Y = 0 | Y = 0 ] instead of simply ϵ 0 for the accuracy on class 0 .

̸

Let f ∗ ( xU ) = Pr [ Y = 1 | XU = xU ] denote the true regression function, and let h ∗ ( xU ) = 1 { f ∗ ( xU ) > 0.5 } denote the Bayes-optimal classifier. It is well known that the Bayes-optimal classifier h ∗ has the maximum possible accuracy out of all classifiers. Thus, the sub-optimality of a classifier h can be measured by the probability S ( h ) = Pr XU [ h ( XU ) = h ∗ ( XU )] that it disagrees with the Bayes-optimal classifier. Our next result expresses S ( h ) in terms of the true regression function f ∗ , the functions ϵ 0 and ϵ 1 , and the distribution of XU , when h is the bias-corrected classifier

from Thm. 4.4 or when h is the 'naive' classifier

that simply treats the pseudo-labels as true labels.

Proposition I.1.

These two formulae for S ( hBC ) and S ( hNaive ) differ only in the numerator of the right-hand side; letting Z : = ϵ 0 ( XU ) -ϵ 1 ( XU ) , the sub-optimality of hBC scales with | Z -E [ Z ] | , whereas the sub-optimality of hNaive scales with | Z | . Intuitively, for all except very pathological random variables Z , | Z -E [ Z ] | is typically smaller than | Z | . Although not a rigorous proof that the bias correction is always better than the naive classifier, this analysis provides an argument that, in most cases, the bias correction should improve on the accuracy of the naive classifier, by making it agree more often with the Bayes-optimal classifier.

We conclude by sketching the proof of Proposition I.1:

Proof. By construction, a thresholding classifier h ( x ) = 1 { f ( x ) > 0.5 } disagress with the Bayesoptimal classifier if and only if

Expanding these inequalities in the cases f ( x ) = Pr [ ̂ Y = 1 | XU = x ]+ ϵ 0 -ϵ 1 ϵ 0 + ϵ 1 -1 and f ( x ) = Pr [ ̂ Y = 1 | XU = x ] and solving for the quantity f ∗ ( x ) -0.5 in each case gives Proposition I.1.

Peer reviews:
comments: SUMMARY:
The authors present a method for training models that are robust to out-of-distribution data by focusing on stable features. Stable features are those whose conditional relationship with the label do not change across domains. The benefit of their approach is demonstrated 1 synthetic dataset and 3 "real-world" datasets.

STRENGTHS:
Spurious correlations is a significant problem in many applications, which erodes the power of predictive models and shortens their usable life. The method proposed by the authors helps to mitigate these issues. 

The paper is well written and easy to follow. The proposed algorithm appears easy to use and computationally scalable.

WEAKNESSES:
This work is closely related to Puli et al. (2021). I think the authors should consider comparing against NURD as well.

Puli, Aahlad, et al. "Out-of-distribution generalization in the presence of nuisance-induced spurious correlations." arXiv preprint arXiv:2107.00520 (2021).

Does line 243 have a typo? What is \epsilon_1?

Algorithm 1 (listing) could use some text describing each step.

In Table 3, please bold the best non-oracle accuracy.

QUESTIONS:
How can one know whether two feature sets are complementary? Are there any tests for that?

What if the stable features cannot be fully isolated? For example, in Puli et al. the authors need only grab the border of images to define the spurious variables but that leaves the center of the image as a mixture of spurious and non-spurious content.

LIMITATIONS:
The authors have adequately addressed limitations.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 4
DATE: 2023-06-30

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis work considers unsupervised domain adaptation, where a learner observes labeled data from multiple source domains and unlabeled data from a target domain, and needs to produce a classifier that works well for data from the target domain. In contrast to the domain generalization setting where no data is available from the target domain, here, the learner can be less conservative and use features that are spurious (unstable or domain-specific) but help improve performance on the target domain. The main challenge is to do this with only unlabeled examples from the target domain.\n\nThe main result of this work (Theorem 4.4) specifies a sufficient condition under which it is possible to use domain-specific features to boost the performance of a conservative classifier that relies on stable features only. Given stable features $X_S$ (i.e., $Y | X_S$ is invariant across domains) and unstable features $X_U$, such that $X_U  \\perp X_S \\mid Y$ (complementarity) and $X_S$ is informative about $Y$, they express $p_\\text{target}(Y | X_S, X_U)$ in terms of $p_\\text{target}(X_S, X_U)$ and $p(Y | X_S)$, both of which can be estimated in the unsupervised domain adaptation setting. Essentially, it reduces to predicting pseudo-labels $\\widehat{Y} \\sim p(Y|X_S)$ from the unstable features $X_U$ and combining it with $p(Y|X_S)$ to construct a classifier that uses both $X_S$ and $X_U$.\n\nBesides this the authors propose a representation learning method that separates stable and unstable features, such that they also satisfy the complementarity assumption. They evaluate their method on a few synthetic datasets, CMNIST, PACS, and Camelyon-17. The results indicate improvement compared to domain generalization methods (i.e., without an adaptation step).\n\nSTRENGTHS:\n**Strength #1: Significance.**  Unsupervised domain adaption is an important and relevant setting for the NeurIPS community. The main result (Theorem 4.4) is a solid contribution to the list of conditions under which some form of out-of-domain generalization (with or with adaptation) becomes possible. I like how the problem of label shift that is a challenge for many methods, is handled naturally in the proposed approach.\n\n**Strength #2: Originality.** As far as I know, the main result (Theorem 4.4) is novel. The fact that in population-level analysis even slight informativeness of $X_S$ for $Y$ allows recovering the true conditional distribution $P(Y|X_S,X_U)$ is not trivial.\n\nWEAKNESSES:\n**Weakness #1: Clarity & Presentation.** The clarity of the presentation can be improved. The notation is not consistent in many cases. Many important discussions/details are presented in appendices, while the main text space is not used effectively. Please see more detailed comments below.\n\n**Weakness #2: Limitations.** \n1. In Theorem 4.4, it is assumed that we have access to stable $X_S$ and unstable features $X_U$. This assumption is quite strong, as one can argue that finding stable and unstable features is one of the key steps in out-of-domain generalization. To my best knowledge there are no methods that extract and separate stable and unstable features well.\n2. In Theorem 4.4, it is also assumed that we have access to the Bayes probabilities $P(Y|X_1)$, where $X_1$ are the stable features. In practice this is not easy to achieve.\n3. The proposed algorithm to extract stable and unstable complementary features has many hyper-parameters. It is unclear to me how sensitive is the method to these hyper-parameters and how easy it is to tune them.\n4. The proposed method requires enforcing stability and complementarity, which is challenging. Not only it is hard to enforce these conditions on source domains (e.g., limitations of conditional HSIC), but the same OOD generalization concern arises -- do these conditions enforced on source domains carry over to the target domain? For this reason, the work will benefit significantly from evaluations targeted to reveal how well the proposed representation learning approach achieves stability and complementarity (rather than evaluating only target domain performance after adaptation).\n\nQUESTIONS:\n- Lines 112 - 116: It should specified what is meant by *relationship* between a feature $X$ and the label $Y$ (i.e., the conditional distribution of $Y|X$). I understand that stable and unstable features are defined later, but at this point of the text reader does not know it and can only guess.\n- Line 115: I think it should be more exact what $X_S$ and $X_U$ are. As I understand from eq. (3.1) they are not subsets of the components of $X$, but rather extracted features: i.e., $X_S = \\Phi_S(X)$ and $X_U = \\Phi_U(X)$.\n- Lines 126-127: This sentence is not rigorous enough.\n- Eq (3.1): It should be $f^e_U(X)$. Also, in (3.1) and (3.2) it should be $h^e_U$ instead of $h^e$.\n- Line 131: $f^s(X)$ -> $f_S(X)$.\n- Lines 137-143: A separate letter should be used to denote the new environment (using $e$ for everything is confusing). Also, the usage of $h_U$ or $h_U^e$ is inconsistent. Why is there a sum over training environments in eq. (3.3)? Shouldn't it be just optimizing for the domain-specific classifier on the target data given already trained $\\Phi_S, \\Phi_U,$ and $h_S$?\n- Line 163: It should be $\\sigma \\circ h_U \\circ \\Phi_U$.\n- Definition 4.3. It should be $X_S \\perp Y \\mid E$.\n- Theorem 4.4: It is worth to mention in the statement that $\\epsilon_0$ and $\\epsilon_1$ can be expressed in terms of $P(Y|X_1)$ and $P(X_1)$.\n- Lines 295-305 (recap and learning goals): I suggest to remove this part. Instead you can bring some parts from the appendix to the main text (e.g., Appendices A.2, H or I).\n- Line 309, objective function: Do I understand correctly that during this first phase you have one domain-specific classifier $h^e_U$ per domain? If so, is the point to make sure that you learn meaningful $\\Phi_U$, rather than a constant function? In that case one can argue that if there is a new kind of spurious features available for the target domain, that might not be picked in this first phase of training.\n- Do the results in the main text use multiple rounds of pseudo-labeling?\n- Are there no suitable unsupervised domain adaptation methods to compare the proposed approach with?\n\nLIMITATIONS:\nThe authors listed assumption of complementarity in Theorem 4.4 as the main limitation of their work. To me this assumption itself is not a big limitation, as it is satisfied in many cases. The main limitation is finding a representation of data that separates stable and unstable features (see my comments on limitations in the \"weaknesses\" section).", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-01"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nUnlike the common trend in the out-of-distribution generalization literature in the presence of spurious correlation, this paper takes a different approach. They argue that the spurious feature could be utilized to enhance the performance of the classifier. Then they go on to show how unlabelled data in the test domain can be used to train a classifier that adaptively uses the spurious/unstable feature (along with the stable features) to get near optimal prediction performance.\n\nSTRENGTHS:\n**Clarity**: This paper is very well-written and easy to follow with appropriate connections between theory and experiments. \n\n**Significance**:\n1. The majority of current literature in the OOD generalization in the presence of the spurious correlation is focused on learning a predictor that only uses the stable feature and thus generalizes across different environments. In doing so they throw away (possibly) easy-to-learn and highly predictive features for the given task since their correlation is likely to change across domains. \n2. This work is an important step in the direction of adaptively making use of the spurious feature without any need for extra labels in the test domains. \n\n**Theory**:\n1. Gave sufficient conditions under which we can train an adaptive classifier that could use unlabeled data in the test domain to use the spurious/unstable feature. \n2. Show how to estimate the prediction probability using an individual classifier that only uses stable or unstable features. \n\n**Experiment**:\nDemonstrate that their method achieves near-optimal performance on synthetic datasets where the assumption of their method holds.\n\nWEAKNESSES:\n**Experiment**:\n1. QRM baseline for the syn, Camelyon, and PACS datasets are not available. \n2. Possible experiment on other real-world datasets where we expect the assumption made in the paper to hold: otherwise it is performing almost equivalently on Camelyon17 and PACS.\n\nQUESTIONS:\n**Minor Typos**:\n1. Line 210: X_{S} \\not\\perp Y |E \n2. Line 651: 4th line of the equation: Extra bracket after $\\epsilon_{1}$ and $Pr[Y=1|X_2]$ instead of $Pr[Y=1|X_2]$.\n\nLIMITATIONS:\nNA", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces a method to utilize spurious features when they are assumed to carry complementary information for predictions. A main contribution is to show that with unlabeled test samples, it is possible to learn how to use spurious features in the test domain. Based on the assumption that both stable feature $X_S$ and spurious feature $X_U$ are known, they derived a provably consistent algorithm for unsupervised test-domain adaptation. They further propose a new training objective function to learn $X_S$ and $X_U$ simultaneously when we have multiple training domains, based on the complementarity assumption ($X_S$ ⊥ $X_U$|$Y$). The full algorithm, including training and test domain adaptation, is named Stable Feature Boosting (SFB). The effectiveness of the test adaptation part of SFB is theoretically proved to be consistent. The whole SFB is empirically shown effective on both real and synthetic datasets.\n\nSTRENGTHS:\n- Originality: good. It is a new exploration on how to harness spurious features.\n- This paper shows a comprehensive theoretical analysis of the adaptation problem.\n- This paper is well written and easy to follow. Experiment settings are well introduced.\n\nWEAKNESSES:\n- Incomplete related works and baselines. As this work assumes the access to a set of unlabeled samples from the test domain, its setting is domain adaptation but not domain generalization. As a result, related works on domain adaption should be discussed and compared so that we can judge the contribution of this work. However, only domain generalization methods are compared, which could be unfair as different knowledge are assumed.\n- IID accuracies are not shown. It is unclear how the SFB affect the IID performance.\n- Missing ablation studies for the new training objective function of SFB.\n\nQUESTIONS:\n- How about the IID performance of SFB?\n- What stability penalty is used to define $P_{Stability}$ in the experiments? How the quality of learning $X_S$ may effect the OOD performance of SFB w. adapt?\n- How this work can be distinguished from existing domain adaptation methods?\n\nLIMITATIONS:\nThe authors have underlined the complementarity assumption as a limitation. Besides, the estimation of $P_{X_S, X_U}$ is challenging in practice when the two variables are high dimensional. Furthermore, this adaptation method is theoretically useful only when $X_S$ is partially predictive.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-09"}