<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>PAC Prediction Sets Under Label Shift</title></titleStmt>
			<publicationStmt>
				<publisher>ICLR</publisher>
				<date>04/01/2024</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10519618</idno>
					<idno type="doi"></idno>
					
					<author>W Si</author><author>S Park</author><author>E Dobriban</author><author>I Lee</author><author>O Bastani</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Prediction sets capture uncertainty by predicting sets of labels rather than individual labels, enabling downstream decisions to conservatively account for all plausible outcomes. Conformal inference algorithms construct prediction sets guaranteed to contain the true label with high probability. These guarantees fail to hold in the face of distribution shift, which is precisely when reliable uncertainty quantification can be most useful. We propose a novel algorithm for constructing prediction sets with PAC guarantees in the label shift setting, where the probabilities of labels can differ between the source and target distributions. Our algorithm relies on constructing confidence intervals for importance weights by propagating uncertainty through a Gaussian elimination algorithm. We evaluate our approach on four datasets: the CIFAR-10 and ChestX-Ray image datasets, the tabular CDC Heart Dataset, and the AGNews text dataset. Our algorithm satisfies the PAC guarantee while producing smaller prediction set sizes compared to several baselines.We leverage the method of (Park et al., 2021) to handle estimation error in the importance weights. That work studies covariate shift, and uses a heuristic to obtain intervals around the importance weights. For the label shift setting, we can in fact obtain stronger guarantees: we modify Gaussian]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>Uncertainty quantification can be a critical tool for building reliable systems from machine learning components. For example, a medical decision support system can convey uncertainty to a doctor, or a robot can act conservatively with respect to uncertainty. These approaches are particularly important when the data distribution shifts as the predictive system is deployed, since they enable the decision-maker to react to degraded performance.</p><p>Conformal prediction <ref type="bibr">(Vovk et al., 2005;</ref><ref type="bibr">Angelopoulos &amp; Bates, 2021</ref>) is a promising approach to uncertainty quantification, aiming to outputs sets of labels instead of a single label. Under standard assumptions (i.i.d. or exchangeable data), it guarantees that the prediction set contains the true label with high probability. We consider probably approximately correct (PAC) (or calibration-setconditional) guarantees <ref type="bibr">(Vovk, 2012;</ref><ref type="bibr">Park et al., 2019)</ref>, which ensure high probability coverage over calibration datasets used to construct the prediction sets.</p><p>In this paper, we propose a novel prediction set algorithm that provides PAC guarantees under the label shift setting, where the distribution of the labels may shift, but the distribution of covariates conditioned on the labels remains fixed. For instance, during a pandemic, a disease may spread to a much larger fraction of the population, but the manifestations of the disease may remain the same. As another example, real-world data may have imbalanced classes, unlike the balanced classes typical of curated training datasets. We consider the unsupervised domain adaptation setting <ref type="bibr">(Ben-David et al., 2006)</ref>, where we are given labeled examples from a source domain, but only unlabeled examples from the target domain, and care about performance in the target domain.</p><p>A standard way to adapt conformal inference to handle distribution shift is by using importance weighting to "convert" data from the source distribution into data from the target distribution <ref type="bibr">(Tibshirani et al., 2019)</ref>. In the label shift setting, one possible way to express the importance weights is w * = C -1 P q * , where C P is the confusion matrix and q * is the distribution of predicted labels <ref type="bibr">(Lipton et al., 2018)</ref>; see details below. However, the estimation error for the unknown C P and q * breaks the PAC guarantee. An example of our approach on the ChestX-ray dataset. In the unshifted setting, standard PAC prediction sets guarantee high-probability coverage, but this guarantee fails under label shift. Our approach addresses this challenge and continues to work in the shifted environment.</p><p>Instead, we construct confidence intervals around C P and q * , and then devise a novel algorithm to propagate these intervals through the Gaussian elimination algorithm used to compute w * . Finally, we leverage an existing strategy for constructing PAC prediction sets when given confidence intervals for the importance weights <ref type="bibr">(Park et al., 2021)</ref>.</p><p>We empirically evaluate our approach on four datasets across three application domains: CIFAR-10 ( <ref type="bibr">Krizhevsky et al., 2009)</ref> in the computer vision domain, the CDC Heart Dataset (Centers for Disease Control and Prevention (CDC), 1984) and ChestX-ray (National Institutes of Health and others, 2022) in the medical domain, and AGNews <ref type="bibr">(Zhang et al., 2015)</ref> in the language domain.</p><p>Contributions. We propose a novel algorithm for constructing PAC prediction sets in the presence of label shift, which computes provably valid intervals around the true importance weights. Our algorithm is based on a technique for propagating confidence intervals through the updates of Gaussian elimination, which to our knowledge is a novel approach to uncertainty propagation in a prediction set construction setting. Finally, we empirically demonstrate that our approach satisfies the PAC guarantee while constructing smaller prediction sets than several baselines.</p><p>Example. Figure <ref type="figure">1</ref> illustrates a use case of our technique on the ChestX-ray dataset. In medical settings, prediction sets (denoted PS) provide a rigorous way to quantify uncertainty for making downstream decisions. In particular, they can guarantee that the prediction set contains the true label (in this case, a diagnosis) with high probability. However, label shift happens commonly in medical settings, for instance, many illnesses have varying rates of incidence over time even when the patient population remains the same. Unfortunately, label shift breaks the PAC coverage guarantee. Our approach (denoted PSW) corrects for the label shift via importance weighting; it does so in a provably correct way. The resulting prediction sets satisfy the PAC guarantee.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Related work.</head><p>There has been recent interest in conformal inference under distribution shift, much of it focusing on covariate shift <ref type="bibr">(Tibshirani et al., 2019;</ref><ref type="bibr">Lei &amp; Cand&#232;s, 2021;</ref><ref type="bibr">Qiu et al., 2022)</ref>. <ref type="bibr">(Podkopaev &amp; Ramdas, 2021)</ref> develop methods for marginal coverage under label shift, whereas we are interested in training-set conditional-or PAC-guarantees. Furthermore, they formally assume that the true importance weights are known exactly, which is rarely the case. In the label shift setting, the importance weights can be estimated <ref type="bibr">(Lipton et al., 2018)</ref>, but as we show in our experiments, uncertainty in these estimates must be handled for the PAC guarantee to hold. elimination to propagate uncertainty through the computation of the weights w * = C -1 P q * . We give a more comprehensive discussion of related work in Appendix A.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">PROBLEM FORMULATION</head><p>2.1 BACKGROUND ON LABEL SHIFT Consider the goal of training a classifier g : X &#8594; Y, where X &#8838; R d is the covariate space, and Y = [K] = {1, ..., K} is the set of labels. We consider the setting where we train on one distribution P over X &#215; Y-called the source-with a probability density function (PDF) p : (x, y) &#8594; p(x, y), and evaluate on a potentially different test distribution Q-called the target-with PDF q : (x, y) &#8594; q(x, y). We focus on the unsupervised domain adaptation setting <ref type="bibr">(Ben-David et al., 2007)</ref>, where we are given an i.i.d. sample S m &#8764; P m of m labeled datapoints, and an i.i.d. sample of n unlabeled datapoints T n X &#8764; Q n X . The label shift setting <ref type="bibr">(Lipton et al., 2018)</ref> assumes that only the label distribution Q Y may be change from P Y , and the conditional covariate distributions remain the same:</p><p>We denote p(y) = P Y (Y = y) for all y &#8712; Y and analogously for Q. <ref type="bibr">(Lipton et al., 2018)</ref> consider two additional mild assumptions: Assumption 2.2. For all y &#8712; Y such that q(y) &gt; 0, we have p(y) &gt; 0.</p><p>Next, given the trained classifier g :</p><p>This last assumption requires that the per-class expected predictor outputs be linearly independent; for instance, it is satisfied when g is reasonably accurate across all labels. In addition, one may test whether this assumption holds <ref type="bibr">(Lipton et al., 2018)</ref>.</p><p>Denoting the importance weights w * := (q(y)/p(y)) y&#8712;Y &#8712; R K , and &#375; := g(x), we will write p(&#375;|y) = P (X,Y )&#8764;P [g(X) = &#375;|Y = y], and define p(&#375;, y), p &#375; as well as the corresponding expressions for q analogously. Since &#375; depends only on x, we have q(&#375; | y) = p(&#375; | y). Thus, see e.g., <ref type="bibr">Lipton et al. (2018)</ref>,</p><p>or in a matrix form, q * = C P w * , where q * := (q &#375; ) &#375;&#8712;Y &#8712; R K . As we assume C P is invertible,</p><p>Our algorithm uses this equation to approximate w * , and then use its approximation to construct PAC prediction sets that remain valid under label shift.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">PAC PREDICTION SETS UNDER LABEL SHIFT</head><p>We are interested in constructing a prediction set C : X &#8594; 2 Y , which outputs a set of labels C(x) &#8838; Y for each given input x &#8712; X rather than a single label. The benefit of outputting a set of labels is that we can obtain correctness guarantees such as:</p><p>where &#949; &#8712; (0, 1) is a user-provided confidence level. Then, downstream decisions can be made in a way that accounts for all labels y &#8712; C(x) rather than for a single label. Thus, prediction sets quantify uncertainty. Intuitively, equation 2 can be achieved if we output C(x) = Y for all x &#8712; X , but this is not informative. Instead, the typical goal is to output prediction sets that are as small as possible.</p><p>The typical strategy for constructing prediction sets is to leverage an fixed existing model. In particular, we assume given a scoring function f : X &#215; Y &#8594; R; most deep learning algorithms provide such scores in the form of predicted probabilities, with the corresponding classifier being g(x) = arg max y&#8712;Y f (x, y). The scores do not need to be reliable in any way; if they are unreliable, the PAC prediction set algorithm will output larger sets. Then, we consider prediction sets parameterized by a real-valued threshold &#964; &#8712; R:</p><p>In other words, we include all labels with score at least &#964; . First, we focus on correctness for P , in which case we only need S m , usually referred to as the calibration set. Then, a prediction set algorithm constructs a threshold &#964; (S m ) &#8712; R and returns C &#964; (Sm) .</p><p>Finally, we want &#964; to satisfy (2); one caveat is that it may fail to do so due to randomness in S m . Thus, we allow an additional probability &#948; &#8712; R of failure, resulting in the following desired guarantee:</p><p>Vovk (2012); <ref type="bibr">Park et al. (2019)</ref> propose an algorithm &#964; that satisfies (3), see Appendix B.</p><p>Finally, we are interested in constructing PAC prediction sets in the label shift setting, using both the labeled calibration dataset S m &#8764; P m from the source domain, and the unlabeled calibration dataset T X n &#8764; Q n from the target distribution. Our goal is to construct &#964; (S m , T X n ) based on both S m and T X n , which satisfies the coverage guarantee over Q instead of P :</p><p>Importantly, the inner probability is over the shifted distribution Q instead of P .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">ALGORITHM</head><p>To construct prediction sets valid under label shift, we first notice that it is enough to find elementwise confidence intervals for the importance weights w * . Suppose that we can construct</p><p>Then, when adapted to our setting, the results of <ref type="bibr">Park et al. (2021)</ref>-originally for the covariate shift problem-provide an algorithm that returns a threshold &#964; (S m , V, W, b), where V &#8764; Uniform([0, 1]) K is a vector of random variables, such that</p><p>(5) This is similar to equation 4 but it accounts for the randomness used by our algorithm-via V -in the outer probability. We give the details in Appendix C.</p><p>The key challenge is to construct W = k&#8712;Y [w k , w k ] such that w * &#8712; W with high probability. The approach from <ref type="bibr">Park et al. (2021)</ref> for the covariate shift problem relies on training a source-target discriminator, which is not possible in our case since we do not have class labels from the target domain. Furthermore, <ref type="bibr">Park et al. (2021)</ref>'s approach is does not provide conditions under which one can provide a valid confidence interval for the importance weights in their setting.</p><p>Our algorithm uses a novel approach, where we propagate intervals through the computation of importance weights. The weights w * are determined by the system of linear equations C P w * = q * . Since C P and q * are unknown, we start by constructing element-wise confidence intervals</p><p>with probability at least 1 -&#948; over our calibration datasets S m and T X n . We then propagate these confidence intervals through each step of Gaussian elimination, such that at the end of the algorithm, we obtain confidence intervals for its output-i.e., w * &#8804; w * &#8804; w * with probability at least 1 -&#948;.</p><p>Finally, we can use (7) with the algorithm from <ref type="bibr">(Park et al., 2021)</ref> to construct PAC prediction sets under label shift. We describe our approach below.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">ELEMENTWISE CONFIDENCE INTERVALS FOR C P AND q *</head><p>Recall that C P = (c ij ) ij&#8712;Y and q * = (q k ) k&#8712;Y . Note that</p><p>Similarly, q k is the mean of 1(g(X) = k) over the randomness in X &#8764; Q X . Thus, we can use the Clopper-Pearson (CP) intervals <ref type="bibr">(Clopper &amp; Pearson, 1934)</ref> for a Binomial success parameter to construct intervals around c ij and q k . Given a confidence level &#948; &#8712; (0, 1) and the sample mean &#265;ij =<ref type="foot">foot_0</ref> m (x,y)&#8712;Sm 1(g(x) = i, y = j)-distributed as a scaled Binomial random variable-this is</p><p>Similarly, for q k , we can construct CP intervals based on qk = 1</p><p>for confidence levels &#948; ij and &#948; k chosen later, we obtain for all i, j, k &#8712; [K],</p><p>Then, the following result holds by a union bound: Given any</p><p>(9)</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">GAUSSIAN ELIMINATION WITH INTERVALS</head><p>We also need to set up notation for Gaussian elimination, which requires us to briefly recall the algorithm. To solve C P w * = q * , Gaussian elimination (see e.g., Golub &amp; Van Loan, 2013) proceeds in two phases. Starting with c 0 = C P and q 0 = q * , on iteration t &#8805; 1, Gaussian elimination uses row k = t to eliminate the kth column of rows i &#8712; {k + 1, ..., K} (we introduce a separate variable k for clarity). In particular, if c t kk &#824; = 0, we denote</p><p>If c t kk = 0, but there is an element j &gt; k in the kth column such that c t jk &#824; = 0, the kth and the jth rows are swapped and the above steps are executed. If no such element exists, the algorithm proceeds to the next step. At the end of the first phase, the matrix c K-1 has all elements below the diagonal equal to zero-i.e., c K-1 ij = 0 if j &lt; i. In the second phase, the Gaussian elimination algorithm solves for w * i backwards from i = K to i = 1, introducing the following notation. For each i, if</p><p>, where</p><p>In our setting, we do not know c 0 and q 0 ; instead, we assume given entrywise confidence intervals as in equation 6, which amount to c 0 &#8804; c 0 &#8804; c 0 and q 0 &#8804; q 0 &#8804; q 0 . We now work on the event &#8486; that these bounds hold, and prove that our algorithm works on this event; later, we combine this result with Equation <ref type="formula">9</ref>to obtain a high-probability guarantee. Then, our goal is to compute c t , c t , q t , q t such that for all iterations t &#8712; {0, 1, ..., K -1}, we have elementwise confidence intervals specified by c t , c t , q t and c t for the outputs c t , q t of the Gaussian elimination algorithm:</p><p>The base case t = 0 holds by the assumption. Next, to propagate the uncertainty through the Gaussian elimination updates for each iteration t &#8712; [K -1], our algorithm sets</p><p>for the lower bound, and computes</p><p>for the upper bound. The first case handles the fact that Gaussian elimination is guaranteed to zero out entries below the diagonal, and thus these entries have no uncertainty remaining. The second rule constructs confidence intervals based on the previous intervals and the algebraic update formulas used in Gaussian elimination for the entries for which i, j &gt; k. For instance, the above confidence intervals use that on the event &#8486;, and by induction on t, if c t ij &#8805; 0 and c t ii &gt; 0 for all i, j &#8712; [K] and for all t, the Gaussian elimination update c t+1 ij = c t ij -c t it c t tj /c t tt can be upper bounded as</p><p>The assumptions that c t ij &#8805; 0 and c t ii &gt; 0 for all i, j &#8712; [K] and for all t may appear a little stringent, but the former can be removed at the cost of slightly larger intervals propagated to the next step, see Section D. The latter condition is satisfied by any classifier that obtains sufficient accuracy on all labels. We further discuss these conditions in Section D. The third rule in equation 11 and equation 12 handles the remaining entries, which do not change; and thus the confidence intervals from the previous step can be used. The rules for q are similar, and have a similar justification:</p><p>For these rules, our algorithm assumes q t i &#8805; 0 for all i &#8712; [K] and all t, and raises an error if this fails. As with the first condition above, this one can be straightforwardly relaxed; see Appendix D.</p><p>In the second phase, we compute w * i starting from i = K and iterating to i = 1. On iteration i, we assume we have the confidence intervals w * j &#8804; w * j &#8804; w * j for j &gt; i. Then, we compute confidence intervals for the sum s i , with a similar justification based on the Gaussian elimination updates:</p><p>and show that they satisfy s i &#8804; s i &#8804; s i on the event &#8486;. Finally, we compute confidence intervals for w * i , assuming c K-1 ii &gt; 0:</p><p>for which we can show that they satisfy w * i &#8804; w * i &#8804; w * i based on the Gaussian elimination updates. Letting W = {w | w * &#8804; w &#8804; w * }, we have the following (see Appendix E for a proof). Lemma 3.1 (Elementwise Confidence Interval for Importance Weights). If (6) holds, and for all i, j, t</p><p>We mention here that the idea of algorithmic uncertainty propagation may be of independent interest.</p><p>In future work, it may further be developed to other methods for solving linear systems (e.g., the LU decomposition, Golub &amp; Van Loan ( <ref type="formula">2013</ref>)), and other linear algebraic and numerical computations.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">OVERALL ALGORITHM</head><p>Algorithm 1 summarizes our approach. As can be seen, the coverage levels for the individual Clopper-Pearson intervals are chosen to satisfy the overall 1 -&#948; coverage guarantee. In particular, the PAC guarantee equation 4 follows from equation 5, equation 9, Lemma 3.1, and a union bound; we provide a more detailed explanation in Appendix F. Theorem 3.2 (PAC Prediction Sets under Label Shift). For any given &#949;, &#948; &#8712; (0, 1), under Assumptions 2.1, 2.2 and 2.3, if &#8704;i, j, t &#8712; [K], we have c t ij &#8805; 0, c t ii &gt; 0, and q t i &#8805; 0, then Algorithm 1 satisfies</p><p>As discussed in Appendix D, we can remove the requirement that c t ij &#8805; 0 and q t i &#8805; 0 for i &#824; = j.</p><p>Algorithm 1 PS-W: PAC prediction sets in the label shift setting.</p><p>11: return c, c, q, q 12: procedure INTERVALGAUSSIANELIM(c 0 , c 0 , q 0 , q 0 ) 13:</p><p>Compute c t ij , c t ij using ( <ref type="formula">11</ref>) &amp; ( <ref type="formula">12</ref>), and q t i , q t i using ( <ref type="formula">14</ref>) 16:</p><p>if c t ij &lt; 0 for some i &#824; = j or c t ii &#8804; 0 for some i or q t i &#8804; 0 for some i, then return &#8709; 17:</p><p>for i &#8712; [K, ..., 1] do 18:</p><p>Compute s t i , s t i using (15), and w i , wi using ( <ref type="formula">16</ref>) 19:</p><p>4 EXPERIMENTS</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">EXPERIMENTAL SETUP</head><p>Predictive models. We analyze four datasets: the CDC Heart dataset, CIFAR-10, Chest X-ray, and the AG News dataset; details are provided in Section 4.2. We use a two-layer MLP for the CDC Heart data with an SGD optimizer having a learning rate of 0.03 and a momentum of 0.9, using a batch size of 64 for 30 epochs. For CIFAR-10, we finetune a pretrained ResNet50 <ref type="bibr">He et al. (2016)</ref>, with a learning rate of 0.01 for 56 epochs. For the ChestX-ray14 dataset, we use a pre-trained CheXNet <ref type="bibr">(Rajpurkar et al., 2017)</ref> with a DenseNet121 <ref type="bibr">(Huang et al., 2017)</ref> backbone with a learning rate of 0.0003 for two epochs. For AGNews, we fine-tune a pre-trained Electra sequence classifier for one epoch with an AdamW optimizer using a learning rate of 0.00001.</p><p>Hyperparameter choices. There are two user-specified hyperparameters that control the guarantees, namely &#948; and &#949;. In our experiments, we choose &#948; = 5 &#215; 10 -4 to ensure that, over 100 independent datasets S m , there is a 95% probability that the error rate is not exceeded. Specifically, this ensures that</p><p>] &#8805; 1 -&#949; holds for all 100 trials, with probability approximately 1 -0.95 1/100 &#8776; 5 &#215; 10 -4 . We select &#949; for each dataset in a way that the resulting average prediction set size is greater than one. This ensures that the coverage guarantee is non-trivial, as a single-valued classifier should not achieve the desired coverage rate (as &#948; is small).</p><p>Dataset construction. We follow the label shift simulation strategies from previous work <ref type="bibr">(Lipton et al., 2018)</ref>. First, we split the full dataset into training data, and "base" source and target datasets.</p><p>We use the training dataset to fit a score function. Given label distributions P Y and Q Y , we generate the source dataset S m , target dataset T X n , and a labeled, size o target test dataset (sampled from Q) by sampling with replacement from the corresponding base datasets. We consider two choices of P Y and Q Y : (i) a tweak-one shift, where change the probability of one label, and keep the relative proportions of the other labels equally likely, and (ii) a general shift, where we shift each probability as described later.</p><p>Baselines. We compare our approach (PS-W) with several baselines (see Appendix G):</p><p>&#8226; PS: PAC prediction sets that do not account for label shift <ref type="bibr">(Vovk, 2012;</ref><ref type="bibr">Park et al., 2019)</ref>. This does not come with PAC guarantees under label shift. &#8226; WCP: Weighted conformal prediction under label shift, which targets marginal coverage <ref type="bibr">(Podkopaev &amp; Ramdas, 2021)</ref>. This does not come with PAC guarantees under label shift either. &#8226; PS-R: PAC prediction sets that account for label shift but ignore uncertainty in the importance weights; again without guarantees. &#8226; PS-C: This addresses label shift via a conservative upper bound on the empirical loss (see Appendix G for details). This is the only baseline with a PAC guarantee under label shift.</p><p>We compare to other baselines in Appendix I.5, and to an oracle with the true weights in Appendix H.</p><p>Results for other hyperparameters are in Appendix I.</p><p>Metrics. We measure performance via the prediction set error, i.e., the fraction of (x, y) &#8764; Q such that y / &#8712; C &#964; (x); and the average prediction set size, i.e., the mean of |C &#964; (x)|, evaluated on the held-out test set. We report the results over 100 independent repetitions, randomizing both dataset generation and our algorithm.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">RESULTS &amp; DISCUSSION</head><p>CDC Heart. We use the CDC Heart dataset, a binary classification problem (Centers for Disease Control and Prevention (CDC), 1984). The goal is to predict the risk of heart attack given features such as level of exercise or weight. We use &#949; = 0.1 and &#948; = 5 &#215; 10 -4 . We consider both large and small shifts. For the large shift, the label distributions-denoted (pos%, neg%)-are (94%, 6%) for  source, and (63.6%, 36.4%) for target; results are in Figure <ref type="figure">2b</ref>. We also consider a small shift with label distributions (94%, 6%) for source, and (91.3%, 8.7%) for target; results are in Figure <ref type="figure">2a</ref>. As can be seen, our PS-W algorithm satisfies the PAC guarantee while achieving smaller prediction set size than PS-C, the only baseline to satisfy the PAC guarantee. The PS and PS-R algorithms violate the PAC guarantee. CIFAR-10. Next, we consider CIFAR-10 ( <ref type="bibr">Krizhevsky et al., 2009)</ref>, which has 10 labels. We use &#949; = 0.1 and &#948; = 5 &#215; 10 -4 . We consider a large and a small tweak-one shift. For the large shift, the label probability is 10% for all labels in the source, 40.0% for the tweaked label, and 6.7% for other labels in the target; results are in Figure <ref type="figure">3a</ref>. For small shifts, we use 10% for all labels for the source, 11.76% for the tweaked label, and 9.8% for other labels for the target; results are in Figure <ref type="figure">3b</ref>. Under large shifts, our PS-W algorithm satisfies the PAC guarantee while outperforming PS-C by a large margin. When the shift is very small, PS-W still satisfies the PAC guarantee, but generates more conservative prediction sets similar in size to those of PS-C (e.g., Figure <ref type="figure">3b</ref>) given the limited data. Results for a non-uniform source distribution and general shifts are shown in Appendix I.8.</p><p>AGNews. AG News is a subset of AG's corpus of news articles <ref type="bibr">(Zhang et al., 2015)</ref>. It is a text classification dataset with four labels: World, Sports, Business, and Sci/Tech. It contains 31,900 unique examples for each class. We use &#949; = 0.05 and &#948; = 5 &#215; 10 -4 . We use tweak-one label shifts. We consider a large shift and a medium-sized calibration dataset, with label distributions equalling (30.8%, 30.8%, 7.7%, 30.8%) for the source, and (12.5%, 12.5%, 62.5%, 12.5%) for the target; results are in Figure <ref type="figure">4a</ref>. As before, our PS-W approach satisfies the PAC guarantee while achieving smaller set sizes than PS-C.</p><p>ChestX-ray. ChestX-ray14 <ref type="bibr">(Wang et al., 2017)</ref> is a medical imaging dataset containing about 112K frontal-view X-ray images of 30K unique patients with fourteen disease labels. This dataset contains  PS PS-C PS-R PS-W WCP 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 prediction set error = 0.05 PS PS-C PS-R PS-W WCP 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 size (a) Prediction set error and size on the AGNews Dataset. Parameters are &#949; = 0.05, &#948; = 5 &#215; 10 -4 , m = 26000, n = 12800, and t = 12800. PS PS-C PS-R PS-W WCP 0.0 0.1 0.2 0.3 0.4 prediction set error = 0.30 PS PS-C PS-R PS-W WCP 0 1 2 3 4 5 size (b) Prediction set error and size on the ChestX-ray dataset. Parameters are &#949; = 0.3, &#948; = 5 &#215; 10 -4 , m = 67200, n = 35200, and o = 3520. instances with multiple labels, which we omit. We also omit classes with few positively labeled datapoints, leaving six classes: Atelectasis, Effusion, Infiltration, Mass, Nodule, Pneumothorax. We consider a general label shift. We consider a large tweak-one shift, with label distributions of (19.1%, . . . , 19.1%, 4.5%, 19.1%) for the source, and (11.1%, . . . , 11.1%, 44.5%, 11.1%) for the target. Results for &#949; = 0.3 are in Figure <ref type="figure">4b</ref>. As before, our PS-W approach satisfies the PAC guarantee while outperforming PS-C. The PS-R and WCP methods violate the constraint.</p><p>Discussion. In all our experiments, our approach satisfies the PAC guarantee; furthermore, it produces smaller prediction set sizes than PS-C-the only baseline to consistently satisfy the PAC guaranteeexcept when the label shift is small and the calibration dataset is limited. In contrast, the PS baseline does not account for label shift, and the PS-R baseline does not account for uncertainty in the importance weights, so they do not satisfy the PAC guarantee. The WCP baseline is designed to target a different guarantee, and it does not satisfy the PAC guarantee. Thus, these results demonstrate the efficacy of our approach.</p><p>Limitations. Our approach is focused on problem settings where the label shift is not too small and sufficient calibration data is available; and may produce conservative prediction sets otherwise. This reflects the intrinsic difficulty of the problem in these settings. Importantly, our PAC coverage guarantees still hold.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">CONCLUSION</head><p>We have proposed a PAC prediction set algorithm for the label shift setting, and illustrated its effectiveness in experiments. Directions for future work include improving performance when the calibration dataset or the label shift is small. Reproducibility statement. Our code is available at <ref type="url">https://github.com/averysi224/  pac-ps-label-shift</ref> for reproducing our experiments.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A ADDITIONAL RELATED WORK</head><p>Conformal Prediction. Our work falls into the broad areas of distribution-free uncertainty quantification, conformal prediction and tolerance regions (e.g., <ref type="bibr">Guttman, 1970;</ref><ref type="bibr">Vovk et al., 2005;</ref><ref type="bibr">Balasubramanian et al., 2014;</ref><ref type="bibr">Angelopoulos &amp; Bates, 2021;</ref><ref type="bibr">Kaur et al., 2022;</ref><ref type="bibr">Li et al., 2022;</ref><ref type="bibr">Dobriban &amp; Yu, 2023, etc)</ref>, which aim to construct prediction sets with finite sample coverage guarantees. The prediction sets are often realized by a setting a threshold on the values of a traditional single-label predictor (i.e. conformity/non-conformity score function) and predict all labels with scores above this threshold. Our setting is related to inductive conformal prediction <ref type="bibr">(Papadopoulos et al., 2002;</ref><ref type="bibr">Vovk, 2012;</ref><ref type="bibr">Lei et al., 2015)</ref>, where the dataset is split into a training set for fitting the scoring function and a calibration set for constructing the prediction sets.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>PAC Prediction Sets.</head><p>A standard coverage guarantee for conformal prediction methods is marginal coverage over the training, calibration and test data. For inductive conformal prediction, training-data conditional correctness <ref type="bibr">(Vovk, 2012;</ref><ref type="bibr">Park et al., 2019)</ref> aims to achieve an (&#949;, &#948;)-coverage guarantee, where coverage over test points exceeds the desired error rate level &#949; with probability at most &#948;. Sets satisfying this guarantee have been termed PAC prediction sets <ref type="bibr">(Park et al., 2019)</ref>. This guarantee is also equivalent to the classical coverage properties of tolerance regions <ref type="bibr">(Wilks, 1941;</ref><ref type="bibr">Fraser, 1956)</ref>. PAC coverage may be desired when a slight excess of the desired error rate cab cause a significant safety concern.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Covariate shift</head><p>Label shift Importance weights, as a function of x, y q(x)/p(x) q(y)/p(y) Shared conditional distribution, for all x, y p(y</p><p>Table 1: Comparison of covariate shift and label shift.</p><p>Label shift. Label shift <ref type="bibr">(Zadrozny, 2004;</ref><ref type="bibr">Huang et al., 2006;</ref><ref type="bibr">Sugiyama et al., 2007;</ref><ref type="bibr">Gretton et al., 2009)</ref> supposes that the conditional covariate distribution is fixed but the label distribution may change from a source to a target distribution; see Table <ref type="table">1</ref>. In more detail, let p and q denote the probability density functions of the source and target domains with respect to a common dominating measure, respectively. Label shift assumes that for all labels y, q(y) may differ from p(y), but for all features x and labels y, we have p(x | y) = q(x | y). Label shift can arise when the representations of the classes changes, for instance in scenarios like medical diagnosis and object recognition <ref type="bibr">(Storkey et al., 2009;</ref><ref type="bibr">Saerens et al., 2002;</ref><ref type="bibr">Lipton et al., 2018)</ref>.</p><p>Early solutions required the estimation of q and p, which may scale poorly with the dimension <ref type="bibr">(Chan &amp; Ng, 2005;</ref><ref type="bibr">Storkey et al., 2009;</ref><ref type="bibr">Zhang et al., 2013)</ref>. More recently, two approaches achieved scalability by assuming an approximate relationship between ground truth labels y and the outputs &#375; of a classifier <ref type="bibr">(Lipton et al., 2018;</ref><ref type="bibr">Azizzadenesheli et al., 2019;</ref><ref type="bibr">Saerens et al., 2002)</ref>: Black Box Shift Estimation (BBSE) <ref type="bibr">(Lipton et al., 2018)</ref> and RLLS <ref type="bibr">(Azizzadenesheli et al., 2019)</ref> provided consistency results and finite-sample guarantees assuming the confusion matrix is invertible. Subsequent work developed a unified framework that decomposes the error in computing importance weights into miscalibration error and estimation error, with BBSE as a special case <ref type="bibr">(Garg et al., 2020)</ref>; this approach was extended to open set label shift domain adaptation <ref type="bibr">(Garg et al., 2022)</ref>. We also mention that label shift is a special case of a more general class of distribution shifts that allow the source and target distributions to be related by sharing sequential conditional distributions <ref type="bibr">(Qiu et al., 2023)</ref>.</p><p>Conformal methods and distribution shift. Conformal prediction has been adapted to distribution shifts such as covariate shift <ref type="bibr">(Tibshirani et al., 2019;</ref><ref type="bibr">Lei &amp; Cand&#232;s, 2021;</ref><ref type="bibr">Qiu et al., 2022)</ref>. <ref type="bibr">(Podkopaev &amp; Ramdas, 2021)</ref> considers label shift when the true importance weights are exactly known. Importance weights are typically estimated with uncertainty. We address this by developing an algorithm to find confidence intervals for the importance weights. More broadly, prediction sets have been studied in the meta-learning setting <ref type="bibr">(Dunn et al., 2022;</ref><ref type="bibr">Park et al., 2022)</ref>, as well as the setting of robustness to all distribution shifts with bounded f -divergence <ref type="bibr">(Cauchois et al., 2020)</ref>.</p><p>Class-conditional prediction sets. Although not designed specifically for solving the label shift problem, methods for class-conditional coverage <ref type="bibr">(Sadinle et al., 2019)</ref> and adaptive prediction sets (APS) <ref type="bibr">(Romano et al., 2020)</ref> can improve robustness to label shifts. However, class-conditional coverage is a stronger guarantee that leads to prediction sets larger than for our algorithm, while APS does not satisfy a PAC guarantee; we compare empirically to these approaches in Appendix I.5. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B BACKGROUND ON PAC PREDICTION SETS</head><p>where k(m, &#949;, &#948;) = max</p><p>Their approach is equivalent to the method from <ref type="bibr">Vovk (2012)</ref>, but formulated in the language of learning theory. By viewing the prediction set as a binary classifier, the PAC guarantee via this construction can be connected to the Binomial distribution. Indeed, for fixed C, LSm (C) has distribution Bionm(m, L P (C)), since 1(y / &#8712; C(x)) has a Bernoulli(L P (C)) distribution when (x, y) &#8764; P . Thus, k(m, &#949;, &#948;) defines a bound such that if L P (C) &#8804; &#949;, then LSm (C) &#8804; k(m, &#949;, &#948;) with probability at least 1 -&#948;.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C BACKGROUND ON PREDICTION SETS UNDER DISTRIBUTION SHIFT</head><p>Here we demonstrate how to obtain prediction sets given intervals w * &#8804; w * &#8804; w * around the true importance weights. This approach is based closely on the strategy in <ref type="bibr">(Park et al., 2021)</ref> for constructing prediction sets under covariate shift, but adapts it to the label shift setting (indeed, our setting is simpler since there are finitely many importance weights). The key challenge is computing the importance weight intervals, which we describe in detail below.</p><p>Given the true importance weights w * , one strategy would be to use rejection sampling <ref type="bibr">(Von Neumann, 1951;</ref><ref type="bibr">Shapiro, 2003;</ref><ref type="bibr">Rubinstein &amp; Kroese, 2016)</ref> to subsample S m to obtain a dataset that effectively consists of N &#8804; m i.i.d. samples from Q (here, N is a random variable, but this turns out not to be an issue). Essentially, for each (x i , y i ) &#8712; S m , we sample a random variable V i &#8764; Uniform([0, 1]), and then accept samples where V i &#8804; w * yi /b, where b is an upper bound on w * y :</p><p>In our setting, we can take b = max y&#8712;Y w * y . Then, we return &#964; (T N (S m , V, w * , b)). Since T N (S m , V, w * , b) consists of an i.i.d. sample from Q, we obtain the desired PAC guarantee (4).</p><p>In practice, we do not know the true importance weights w * . Instead, suppose we can obtain intervals W y = [w * y , w * y ] such that w * y &#8712; W y with high probability. We let W = y&#8712;Y W y , and assume w * &#8712; W with probability at least 1 -&#948;. The algorithm proposed in <ref type="bibr">(Park et al., 2021)</ref> adjusts the above algorithm to conservatively account for this uncertainty-i.e., it chooses &#964; so the PAC guarantee (4) holds for any importance weights w &#8712; W :</p><p>We minimize over &#964; since choosing smaller &#964; leads to larger prediction sets, which is more conservative. <ref type="bibr">(Park et al., 2021)</ref> show how to compute (18) efficiently. We have the following guarantee: Theorem C.1 (Theorem 4 in <ref type="bibr">(Park et al., 2021)</ref>). Assume that w * &#8712; W . Letting U = Uniform([0, 1]),</p><p>In other words, the PAC guarantee (4) holds, with the modification that the outer probability includes the randomness over the samples V &#8764; U m used by our algorithm.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D ENSURING THE CONFIDENCE BOUNDS AT EACH STEP</head><p>The diagonal elements c kk of the confusion matrix of an accurate classifier, are typically much larger than the other elements. Indeed, for an accurate classifier, the probabilities of correct predictions c kk = P (g(x) = k, y = k) are higher than those of incorrect predictions c ik := P (g(x) = i, y = k), i &#824; = k. On the other hand, the Clopper-Pearson interval is expected to be short (for instance, the related Wald interval has length or order 1/ &#8730; m, where m is the sample size). Thus, we expect that</p><p>Without loss of generality, we consider equation 11 as an example. In the Gaussian elimination process, recall that the update at step t is</p><p>Combining with equation 19, the factor by which the k-th row is multiplied is small, i.e., c t ik /c t kk &#8810; 1. Thus the resulting i-th diagonal elements Balanced classifier. For a balanced classifier, when c ik and c jk are close for all i, j such that i &#824; = k, j &#824; = k, since the factor c t ik /c t kk is small, the lower bound in equation 20 is expected to be positive. Imbalanced classifier. For the more general case of a possibly imbalanced classifier, c ij and c kj may not be close. This could cause non-positive bounds at certain steps, so the confidence interval may not be valid at the next steps; e.g., equation 13 may fail. However, note that since</p><p>t ik ], c t kj &#8712; [c t kj , c t kj ], we have c t ik c t kj &#8804; max{|c t ik |, |c t ik |} &#8226; max{|c t kj |, |c t kj |} and hence c t ik c t kj c t kk &#8804; max{|c t ik |, |c t ik |} &#8226; max{|c t kj |, |c t kj |} c t kk . In fact, one can derive the even tighter bound max c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk , c t ik c t kj c t kk .</p><p>This can be checked by carefully going through all possible cases of positive and negative values of the bounds. Similar changes can be made to computing the upper bounds.</p><p>It is possible for our final interval W to contain negative lower bounds due to loose element-wise intervals or other factors. Since importance weights are non-negative, negative importance weight bounds act the same way as zero lower bounds in rejection sampling, and preserve our guarantees.</p><p>Finally, the requirement of an accurate classifier is already imposed by methods such as BBSE to ensure the invertibility of the confusion matrix. Therefore, our Gaussian elimination approach does not impose significantly stronger assumptions.</p><p>E PROOF OF LEMMA 3.1</p><p>For the first phase, we prove by induction on t that (10) holds for all t. The base case t = 0 holds by assumption. For the induction step, we focus on c t+1 ij ; the remaining bounds c t+1 ij , q t+1 k , and q t+1 k follow similarly. There are three sub-cases i, each corresponding to one of the update rules in (11).</p><p>For the first update rule c t+1 ij = 0, equation 10 follows since the Gaussian elimination algorithm guarantees that c t+1 ij = 0. For the second and third update rules, equation 10 follows by direct algebra and the induction hypothesis. For instance, for i, j &gt; t, equation 13 holds, and similarly c t+1 ij &#8805; c t+1 ij . For the second phase, the fact that s &#8804; s &#8804; s and w * &#8804; w * &#8804; w * follows by a similar induction argument. Since Gaussian elimination guarantees that w * = C -1 P q * , and we have shown that w * &#8712; W = K i=1 [w i , w i ], the claim follows.</p><p>F PROOF SKETCH OF THEOREM 3.2 First, Theorem 3.2 follows from equation 5, assuming the given confidence intervals W i = [w i , w i ] for each importance weight w * i is valid-i.e., w * i &#8712; W i . Equation <ref type="formula">5</ref>follows by Theorem 4 in <ref type="bibr">Park et al. (2021)</ref>. Roughly speaking, if w * i is known, then we can use a standard rejection sampling procedure based on w * i to convert S m into a set of i.i.d. samples from Q. Then, the PAC guarantee would follow by standard conformal prediction results, e.g., <ref type="bibr">Park et al. (2020)</ref>. When w * i is not known, then intuitively, <ref type="bibr">Park et al. (2021)</ref> takes the worst case over all w * i &#8712; W i . They use a reparameterization trick to do so in a computationally efficient way. Finally, by Lemma 3.1, we have w * i &#8712; W i for all i &#8712; [n] with high probability, so Theorem 3.2 follows by a union bound.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>G CONSERVATIVE BASELINE</head><p>We describe PS-C, the conservative baseline summarized in Algorithm 2. In particular, given an upper bound b &#8805; w * on the importance weight, we use the upper bound c, c, q, q &#8592; CPINTERVAL(S m , T X n , x &#8594; arg max y&#8712;Y f (x, y), &#948; w ) 3:</p><p>W &#8592; INTERVALGAUSSIANELIM(c, c, q, q) </p><p>Hence, using the PS prediction set algorithm with parameters (&#949;/b, &#948;), the output is (&#949;, &#948;)-PAC.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>H ORACLE IMPORTANCE WEIGHT RESULTS</head><p>Here, we show comparisons to an oracle that is given the ground truth importance weights (which are unknown and must be estimated in most practical applications). It uses rejection sampling according to these weights rather than conservatively accounting for uncertainty in the weights. In contrast to our baselines (which need to estimate w), this oracle represents a "gold (yet not achievable) standard" to compare with. It enables us to quantify the increase in average prediction set size due to uncertainty in our estimates of w, stemming from (i) finite sample error, accounted for by Clopper-Pearson intervals, and (ii) label shift, accounted for by our interval Gaussian elimination algorithm.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>The algorithm requires further discussion if c K-1 ii = 0 (Golub &amp; Van Loan,</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_1"><p>2013); this does not commonly happen in our motivating application so we will not consider this case. See Appendix D for details.</p></note>
		</body>
		</text>
</TEI>
