P REDICTIVE I NFERENCE WITH F EATURE C ONFORMAL P REDICTION
Anonymous authors
Paper under double-blind review
A BSTRACT
Conformal prediction is a distribution-free technique for establishing valid prediction intervals.
Although conventionally people conduct conformal prediction in the output space, this is not the only possibility.
In this paper, we propose feature conformal prediction, which extends the scope of conformal prediction to semantic feature spaces by leveraging the inductive bias of deep representation learning.
From a theoretical perspective, we demonstrate that feature conformal prediction provably outperforms regular conformal prediction under mild assumptions.
Our approach could be combined with not only vanilla conformal prediction, but also other adaptive conformal prediction methods.
Experiments on various predictive inference tasks corroborate the efficacy of our method.
I NTRODUCTION
Although machine learning models work well in numerous fields (Silver et al., 2017; Devlin et al., 2019; Brown et al., 2020), they usually suffer from over-confidence issues, yielding unsatisfactory uncertainty estimates (Guo et al., 2017a;
Chen et al., 2021; Gawlikowski et al., 2021).
To tackle the uncertainty issues, people have developed a multitude of uncertainty quantification techniques, including calibration (Guo et al., 2017b;
Minderer et al., 2021), Bayesian neural networks (Smith, 2014; Blundell et al., 2015), and many others (Sullivan, 2015).
Among different uncertainty quantification techniques, conformal prediction (CP) stands out due to its simplicity and low computational cost properties (Vovk et al., 2005; Shafer & Vovk, 2008; Angelopoulos & Bates, 2021).
Intuitively, conformal prediction first splits the dataset into a training fold and a calibration fold, then trains a machine learning model on the training fold, and finally constructs the confidence band via a non-conformity score on the calibration fold.
Notably, the confidence band obtained by conformal prediction is guaranteed due to the exchangeability assumption in the data.
With such a guarantee, conformal prediction has been shown to perform promisingly on numerous realistic applications (Lei & Cand ` es, 2021b;
Angelopoulos et al., 2022).
Despite its remarkable effectiveness, vanilla conformal prediction (vanilla CP) is only deployed in the output space, which is not the only possibility.
As an alternative, feature space in deep learning stands out due to its powerful inductive bias of deep representation.
Take the image segmentation problem as an example.
In such problems, we anticipate a predictive model to be certain in the informative regions ( e.g. , have clear objects), while uncertain elsewhere.
Since different images would possess different object boundary regions, it is inappropriate to return the same uncertainty for different positions, as standard conformal prediction does.
Nonetheless, if we instead employ conformal prediction on the more meaningful feature space, albeit all images have the same uncertainty on this intermediate space, the pixels would exhibit effectively different uncertainty in the output space after a non-trivial non-linear transformation (see Figure 3).
In this work, we thus propose the Feature Conformal Prediction (Feature CP) framework, which deploys conformal prediction in the feature space rather than the output space (see Figure 1).
However, there are still two issues unsolved for performing Feature CP: (a) commonly used non-conformity scores require a ground truth term, but here the ground truth in feature space is not given; and (b) transferring the confidence band in the feature space to the output space is non-trivial.
To solve problem (a), we propose a new non-conformity score based on the notation surrogate feature, which replaces the ground truth term in previous non-conformity scores.
As for (b), we propose two methods: Band Estimation , which calculates the upper bound of the confidence band, together with
[Figure]
Band Detection , to determine whether a response locates in the confidence band.
More interestingly, feature-level techniques are pretty general and can be deployed into other distribution-free inference algorithms, e.g. , conformalized quantile regression (CQR).
This shows the great potential application impact of the proposed Feature CP methodology (see discussion in Appendix B.4).
From a theoretical perspective, we demonstrate that Feature CP is provably more efficient, in the sense that it yields shorter confidence bands than vanilla CP, given that the feature space meets cubic conditions .
Here the cubic conditions sketch the properties of feature space from three perspectives, including length preserving, expansion, and quantile stability (see Theorem 5).
At a colloquial level, the cubic conditions assume the feature space has a smaller distance between individual non-conformity scores and their quantiles, which reduces the cost of the quantile operation.
We empirically validate that the feature space in deep learning satisfies the cubic conditions, thus resulting in a better confidence band with a shorter length (See Figure 2) according to our theoretical analysis.
Our contributions can be summarized as follows:
• We propose Feature CP, together with a corresponding non-conformity score and an uncertainty band estimation method.
The proposed method no longer treats the trained model as a black box but exploits the semantic feature space information.
What’s more, our approach could be directly deployed with any pretrained model as a plug-in component, without the need of re-training under specially designed learning criteria.
• Theoretical evidence guarantees that Feature CP is both (a) efficient, where it yields shorter confidence bands, and (b) effective, where the empirical coverage provably exceeds the given confidence level, under reasonable assumptions.
• We conduct extensive experiments under both synthetic and realistic settings ( e.g. , pixel-level image segmentation) to corroborate
the effectiveness of the proposed algorithm.
Besides, we demonstrate the universal applicability of our method by deploying feature-level operations to improve other adaptive conformal prediction methods such as CQR.
R ELATED W ORK
Conformal prediction is a statistical framework dealing with uncertainty quantification problems (Vovk et al., 2005; Shafer & Vovk, 2008; Nouretdinov et al., 2011; Barber et al., 2020;
Angelopoulos & Bates, 2021).
The research on conformal prediction can be roughly split into the following branches.
The first line of work focuses on relaxing the assumptions about data distribution in conformal prediction, e.g. , exchangeability (Tibshirani et al., 2019; Hu & Lei, 2020;
Podkopaev & Ramdas, 2021; Barber et al., 2022).
The second line aims at improving the efficiency of conformal prediction (Romano et al., 2020; Sesia & Cand`es, 2020; Izbicki et al., 2020a; Yang & Kuchibhotla, 2021; Stutz et al., 2021).
The third line tries to generalize conformal prediction to different settings, e.g. , quantile regression (Romano et al., 2019), k -Nearest Neighbors (Papadopoulos et al., 2011), density estimator (Izbicki et al., 2020b), survival analysis (Teng et al., 2021; Cand`es et al., 2021), or conditional histogram regression (Sesia & Romano, 2021).
There are also works combining conformal prediction with other machine learning topics, such as functional data (Lei et al., 2013), treatment effects (Lei & Cand`es, 2021a), time series analysis (Xu & Xie, 2021), online learning (Gibbs & Cand`es, 2021), adversarial robustness (Gendler et al., 2022), and many others.
Besides conformal prediction, there are many other uncertainty quantification techniques, including calibration (Guo et al., 2017a;
Kuleshov et al., 2018; Nixon et al., 2019) and Bayesian-based techniques (Blundell et al., 2015; Hern´andez-Lobato & Adams, 2015; Li & Gal, 2017).
Different from the above techniques, conformal prediction is appealing due to its simplicity, computationally free, and model-free properties.
Image segmentation is a traditional task in computer vision, which focuses on partitioning images into different semantic segments (Haralick & Shapiro, 1985; Senthilkumaran & Rajesh, 2009; Minaee et al., 2020).
A line of researches applies conformal prediction with some threshold output for all pixels (Angelopoulos & Bates, 2021; Bates et al., 2021), or focus on the risk control tasks (Angelopoulos et al., 2021).
Different from previous approaches, our method first achieves meaningful pixel-level conformal prediction results to the best of our knowledge.
P RELIMINARIES
Predictive inference.
Let ( X, Y ) ∼ P denotes a random data pair, e.g. , an image and its segmentation map.
Given a significance level α , we aim to construct a confidence band C 1 − α ( X ) , such that
[Equation]
There is a tradeoff between efficiency and effectiveness, since one can always set C 1 − α
( X ) to be infinitely large to satisfy Equation (1).
In practice, we wish the measure of the confidence band ( e.g. , its length) can be as small as possible, given that the coverage in Equation (1) holds.
Dataset.
Let D
= { ( X i , Y i ) } i ∈I denotes the dataset, where I denotes the set of data index and ( X i , Y i ) denotes a sample pair following the distribution P .
Typically, conformal prediction requires that data in D satisfies exchangeability (see below) rather than the stronger i.i.d.
(independent and identically distributed) condition.
We use |I| to represent the cardinality of a set I .
Conformal prediction needs to first randomly split the dataset into a training fold D tr = { ( X i , Y i ) } i ∈I tr and a calibration fold D ca = { ( X i , Y i ) } i ∈I ca , where I tr ∪ I ca =
I and I tr ∩ I ca = ϕ .
We denote the test point as ( X ′ , Y ′ ) , which is also sampled from the distribution P .
Training process.
During the training process, we train a machine learning model denoted by ˆ µ ( · ) ( e.g. , neural network) with the training fold D tr .
For the ease of the following discussion, we rewrite the model as ˆ µ = ˆ g ◦ ˆ f , where ˆ f denotes the feature function ( i.e. , first several layers in neural networks) and ˆ g denotes the prediction head ( i.e. , last several layers in neural networks).
Calibration process.
Different from usual machine learning methods, conformal prediction has an additional calibration process.
Specifically, we calculate a non-conformity score V i
=
s ( X i , Y i , ˆ µ ) based on the calibration fold D ca , where s ( · , · , · ) is a function informally measuring how the model ˆ µ fits the ground truth.
The simplest form of non-conformity score is s ( X i , Y i , ˆ µ ) =
∥
Y i − ˆ µ ( X i ) ∥ .
One could adjust the form of the non-conformity score according to different contexts ( e.g. , Romano et al.
; Teng et al.
Based on the selected non-conformity score, a matching confidence band could be subsequently created.
We present vanilla CP 1 in Algorithm 1.
Moreover, we demonstrate its theoretical guarantee in
Proposition 2, based on the following notation of exchangeability in Assumption 1.
Assumption 1 (exchangeability) .
Assume that the calibration data ( X i , Y i ) , i ∈ I ca and the test point ( X ′ , Y ′ ) are exchangeable.
Formally, define Z i , i = 1 , . .
, |I ca + 1 | , as the above data pair, then Z i are exchangeable if arbitrary permutation leads to the same distribution, i.e.,
[Equation]
with arbitrary permutation π over { 1 , · · · , |I ca + 1 |} .
Note that Assumption 1 is weaker than the i.i.d. assumption.
Therefore, it is reasonable to assume the exchangeability condition to hold in practice.
Based on the exchangeability assumption, one can
[Equation]
show the following theorem, indicating that conformal prediction indeed returns a valid confidence band, which satisfies Equation (1).
Theorem 2 (theoretical guarantee for conformal prediction (Law, 2006; Lei et al., 2018; Tibshirani et al., 2019)) .
Under Assumption 1, the confidence band C 1 − α
( X ′ )
returned by Algorithm 1 satisfies
[Equation]
M ETHODOLOGY
In this section, we broaden the concept of conformal prediction using feature-level operations.
This extends the scope of conformal prediction and makes it more flexible.
We analyze the algorithm components and details in Section 4.1 and Section 4.2.
The algorithm is finally summarized in
Section 4.3.
We remark that although in this work we discuss Feature CP under regression regimes for simplicity’s sake, one can easily extend the idea to classification problems.
4. N ON - CONFORMITY S CORE
Conformal prediction necessitates a non-conformity score to measure the conformity between prediction and ground truth.
Traditional conformal prediction usually uses norm-based non-conformity score due to its simplicity, i.e. , s ( X, Y, µ ) =
∥
Y − µ ( X ) ∥ , where Y is the provided ground truth target label.
Nonetheless, we have no access to the given target features if we want to conduct conformal prediction at the feature level.
To this end, we introduce the surrogate feature (see Definition 3), which could serve as the role of ground truth Y in Feature CP.
Definition 3 (Surrogate feature) .
Consider a trained neural network ˆ µ = ˆ g ◦
ˆ f where ◦ denotes the composition operator.
For a sample ( X, Y ) , we define ˆ v = ˆ f ( X ) to be the trained feature.
Besides, we define the surrogate feature to be any feature v such that ˆ g ( v ) =
Y .
In contrast to commonly adopted regression or classification scenarios where the label is unidimensional, the dimensionality of features could be much larger.
We thus define a corresponding non-conformity score based on the surrogate feature as follows:
[Equation]
It is usually complicated to calculate the score in Equation 3 due to the infimum operator.
Therefore, we design Algorithm 2 to calculate an upper bound of the non-conformity score.
Although the exact infimum is hard to achieve in practice, we can apply gradient descent starting from the trained feature ˆ v to find a surrogate feature v around it.
In order to demonstrate the reasonability of this algorithm, we analyze the non-conformity score distribution with realistic data in Appendix B.6.
4. B AND E STIMATION AND B AND D ETECTION
Utilizing the non-conformity score derived in Section 4.1, one could derive a confidence band in the feature space.
In this section, we mainly focus on how to transfer the confidence band in feature space to the output space, i.e. , calculating the set
[Equation]
Algorithm
Require: Data point ( X, Y ) , trained predictor ˆ g ◦
ˆ f ( · ) , step size η , number of steps M ; 1: u ← ˆ f ( X ) ; 2: m ← 0 ; 3: while m < M do 4: u ← u − η ∂ ∥ ˆ g ( u ) − Y ∥ 2 ∂u ; 5: m ← m + 1 ; 6: end while
Ensure: s ( X, Y, ˆ g ◦ ˆ f ) =
∥
u − ˆ f
( X ) ∥ .
where ˆ v is the trained feature, ˆ g is the prediction head, and Q 1 − α is derived based on the calibration set (even though slightly different, we refer to stepin Algorithm 1 for the notion of Q 1 − α ; a formal discussion of it is deferred to Algorithm 3).
Since the prediction head ˆ g is usually highly nonlinear, the exact confidence band is hard to represent explicitly.
Consequently, we provide two approaches: Band Estimation which aims at estimating the upper bound of the confidence band, and
Band Detection which aims at identifying whether a response falls inside the confidence interval.
We next crystallize the two methods.
Band Estimation.
We model the Band Estimation problem as a perturbation analysis one, where we regard v in Equation (4) as a perturbation of the trained feature ˆ v , and analyze the output bounds of prediction head ˆ g .
In this work, we apply linear relaxation based perturbation analysis (LiPRA) (Xu et al., 2020) to tackle this problem under deep neural network regimes.
LiPRA transforms the certification problem as a linear programming problem, and solves it accordingly.
The relaxation would result in a relatively looser interval than the actual band, so this method would give an upper bound estimation of the exact band length.
Band Detection.
Band Estimation could potentially end up with loose inference results.
Typically, we are only interested in determining whether a point ˜
Y is in the confidence band C ( X ′ ) for a test sample X ′ .
To achieve this goal, we first apply Algorithm 2 using data point ( X ′ , ˜ Y ) , which returns a non-conformity score ˜ V .
We then test whether the score ˜ V is smaller than quantile Q 1 − α on the calibration set (see Equation (4)).
If so, we deduce that ˜ Y ∈ C ( X ′ ) (or vice versa if not).
4. F EATURE C ONFORMAL P REDICTION
Based on the above discussion, we summarize 2 Feature CP in Algorithm 3.
Different from vanilla
CP (see Algorithm 1), Feature CP uses a different non-conformity score based on surrogate features, and we need an additional Band Estimation or Band Detection (step 5) to transfer the band from feature space to output space.
We then discuss two intriguing strengths of Feature CP.
First, the proposed technique is universal and could improve other advanced adaptive conformal inference techniques utilizing the inductive bias of learned feature space.
Specifically, we propose Feature CQR with insights from CQR (Romano et al., 2019), a prominent adaptive conformal prediction method with remarkable performance, to demonstrate the universality of our technique.
We relegate related algorithmic details to Section B.4.
Second, although methods such as CQR require specialized training criteria ( e.g. , quantile regression) for the predictive models, Feature CP could be directly applied to any given pretrained model and could still give meaningful adaptive interval estimates.
This trait facilitates the usage of our method with large pretrained models, which is common in modern language and vision tasks.
T HEORETICAL G UARANTEE
This section provides theoretical guarantees for Feature CP regarding coverage (effectiveness) and band length (efficiency), starting from additional notations.
Notations.
Let P denote the population distribution.
Let D ca ∼ P n denote the calibration set with sample size n and sample index I ca , where we overload the notation P n to denote the distribution of a set with samples drawn from distribution P .
Given the model ˆ g ◦ ˆ f with feature extractor ˆ f and prediction head ˆ g , we assume ˆ g is continuous.
We also overload the notation Q 1 − α
( V ) to denote the (1 − α )
-quantile of the set V ∪ {∞} .
Besides, let M [ · ] denote the mean of a set, and a set minus a real number denote
[Table]
[Table]
Vanilla CP.
Let V o D ca = { v oi } i ∈I ca denote the individual length in the output space for vanilla CP, given the calibration set D ca .
Concretely, v oi = 2 |
y
i − ˆ y i | where y i denotes the true response of sample i and ˆ y i denotes the corresponding prediction.
Since vanilla CP returns band length with 1 − α quantile of non-conformity score, the resulting average band length is derived by Q 1 − α
( V o D ca ) .
Feature CP.
Let V f D ca = { v fi } i ∈I ca be the individual length (or diameter in high dimensional cases) in the feature space for Feature CP, given the calibration set D ca .
To characterize the band length in the output space, we define H ( v, X ) as the individual length on sample X in the output space, given the length v in the feature space, i.e. , H ( v, X ) represents the length of the set { ˆ g ( u ) ∈ R :
∥ u − ˆ f
( X ) ∥
≤ v/ 2 } .
Due to the continuity assumption on function ˆ g , the above set is always simply-connected.
We here omit the dependency of prediction head ˆ g in H for simplicity.
The resulting band length in
Feature CP is denoted by E ( X ′ ,Y ′ )
∼P H ( Q 1 − α
( V f D ca ) , X ′ ) .
Without abuse of notations, operating H on a dataset ( e.g. , H ( V f D ca , D ca ) ) means operating H on each data point ( v fi , X i ) in the set.
Coverage guarantee.
We next provide theoretical guarantees for Feature CP in Theorem 4, which informally shows that under Assumption 1, the confidence band returned by Algorithm 3 is valid, meaning that the coverage is provably larger than 1 − α .
We defer the whole proof to Appendix A.2.
Theorem 4 (theoretical guarantee for Feature CP) .
Under Assumption 1, for any α > 0 , the confidence band returned by Algorithm 3 satisfies:
[Equation]
where the probability is taken over the calibration fold and the testing point ( X ′ , Y ′ ) .
Length (efficiency) guarantee.
We next show in Theorem 5 that Feature CP is provably more efficient than the vanilla CP, whose proof is deferred to Appendix A.1.
Theorem 5 (Feature CP is provably more efficient) .
Assume that the non-conformity score is in norm-type.
For the operator H , we assume a Holder assumption that there exist α > 0 , L > 0 such that |H
( v, X ) − H ( u, X ) | ≤ L | v − u | α for all X .
Besides, we assume that there exists ϵ > 0 , c > 0 , such that the feature space satisfies the following cubic conditions:
Length Preserving.
Feature CP does not cost much loss in feature space in a quantile manner, namely, E D∼P n Q 1 − α
( H ( V f D , D )) <
E D∼P n Q 1 − α
( V o D )
+ ϵ . 2.
Expansion.
The operator H ( v, X ) expands the differences between individual length and their quantiles, namely, L E D∼P n M | Q 1 − α
( V f D ) − V f D | α < E D∼P n M [ Q
[Equation]
Quantile Stability.
Given a calibration set D ca , the quantile of the band length is stable in both feature space and the output space, namely, E D∼P n | Q 1 − α [Equation] V f D ) − Q 1 − α
[Equation]
V f D ca ) | ≤ c √ n and E D∼P n | Q 1 − α ( V o D ) − Q 1 − α
( V o D ca )
| ≤ c √ n
Then Feature CP provably outperforms vanilla CP in terms of average band length, namely,
[Equation]
, where the expectation is taken over the calibration fold and the testing point ( X ′ , Y ′ ) .
[Figure]
The cubic conditions used in Theorem 5 sketch the properties of feature space from different aspects.
The first condition implies that the feature space is efficient for each individual, which holds when the band is generally not too large.
The second condition is the core of the proof, which informally assumes that the difference between quantile and each individual is smaller in feature space.
Therefore, conducting quantile operation would not harm the effectiveness (namely, step 4 in Algorithm 1 and step 4 in Algorithm 3), leading to the efficiency of Feature CP.
The last condition helps generalize the results from the calibration set to the test set.
We provide a more detailed discussion of this theorem in Appendix A.1.
E XPERIMENTS
We conduct experiments on synthetic and real-world datasets, mainly to show that Feature CP is (a) effective, i.e. , it could return valid confidence bands with empirical coverage larger than 1 − α ; (b) efficient, i.e. , it could return shorter confidence bands than vanilla CP.
6. S ETUP
Datasets.
We consider both synthetic datasets and real-world datasets, including (a) realistic unidimensional target datasets: five datasets from UCI machine learning repository (Asuncion, 2007): physicochemical properties of protein tertiary structure (bio), bike sharing (bike), community and crimes (community) and Facebook comment volume variants one and two (facebook 1/2), five datasets from other sources: blog feedback (blog) (Buza, 2014), Tennessee’s student teacher achievement ratio (star) (Achilles et al., 2008), and medical expenditure panel survey (meps19–21) (Cohen et al., 2009); (b) synthetic multi-dimensional target dataset:
Y = WX + ϵ , where X ∈ [0 , 1] 100 , Y ∈ R 10 , ϵ follows the standard Gaussian distribution, and W is a fixed randomly generated matrix; and (c) real-world semantic segmentation dataset: Cityscapes (Cordts et al., 2016), where we transform the original pixel-wise classification problem into a high-dimensional pixel-wise regression problem.
We defer more related details to Appendix B.1.
[Table]
Algorithms.
We compare the proposed Feature CP against the vanilla conformal baseline, which directly deploys conformal inference on the output space.
For both methods, we use ℓ ∞ -type non-conformity score, namely, s ( X, Y, µ ) =
∥
Y − µ ( X ) ∥ ∞ .
Evaluation.
We adopt the following metrics to evaluate algorithmic empirical performance.
Empirical coverage (effectiveness) is the empirical probability that a test point falls into the predicted confidence band.
A good predictive inference method should achieve empirical coverage slightly larger than 1 − α for a given significance level α .
To calculate the coverage for Feature CP, we first apply Band Detection on the test point ( X ′ , Y ′ ) to detect whether Y ′ is in C fcp 1 − α ( X ′ ) , and then calculate its average value to obtain the empirical coverage.
Band length (efficiency).
Given the empirical coverage being larger than 1 − α , we hope the confidence band to be as short as possible.
The band length should be compared under the regime of empirical coverage being larger than 1 − α , otherwise one can always set the confidence band to empty to get a zero band length.
Since the explicit expression for confidence bands is intractable for the proposed algorithm, we could only derive an upper bound of the band length via Band Estimation.
Concretely, we first use Band Estimation to estimate the confidence interval, which returns a band with explicit formulation, and then calculate the average length across each dimension.
We formulate the metrics as follows.
Let Y =
( Y (1) , . . .
, Y ( d ) )
∈
R d denotes the high dimensional response and C ( X ) ⊆
R d denotes the obtained confidence interval, with length in each dimension forming a vector |C ( X ) | ∈ R d .
With the test set index being I te and [ d ] = { 1 , . . .
, d } , we calculate the empirical coverage and band length respectively as
[Equation]
[Figure]
d i ff
[Figure]
f r o m o r a c l
[Figure]
6. R ESULTS AND D ISCUSSION
Effectiveness.
We summarize the empirical coverage in Figure 2 (one-dimension response) and
Table 1 (multi-dimension response).
As Theorem 4 illustrates, the empirical coverage of Feature
CP all exceeds the confidence level 1 − α , indicating that Feature CP is effective.
Besides, Figuredemonstrates that that the effectiveness holds with different significance levels α .
For simple benchmarks such as facebook1 and synthetic data, both methods achieve similar coverage due to the simplicity; while for the harder Cityscapes segmentation task, the proposed method outperforms the baseline under many confidence levels.
Efficiency.
We summarize the confidence band in Figure 2 (one-dimension response) and Table(multi-dimension response).
Note that Feature CP outperforms the baseline in the sense that it achieves a shorter band length and thus a more efficient algorithm.
Comparison to CQR.
The techniques proposed in this paper can be generalized to other conformal prediction techniques.
As an example, we propose Feature CQR which is a feature-level generalized version of CQR, whose details are deferred to Appendix B.4.
We display the comparison in Figure 2, where our method consistently outperforms CQR baseline by leveraging good representation.
Besides, we also evaluate the group coverage performance of CQR and Feature CQR in Appendix B.5, showing that Feature CQR generally outperforms CQR in the sense of condition coverage.
Truthfulness.
We visualize the segmentation results in Figure 3, which illustrates that Feature
CP returns large bands (light region) on the non-informative regions (object boundaries) and small bands (dark region) on the informative regions.
We do not show baseline visualization results since they return the same band in each dimension for each sample, and therefore does not contain much information.
We also evaluate the performance with weighted band length, defined in Appendix B.1.
Why Feature CP works?
We claim it is the usage of good (deep) representation that enables Feature
CP to achieve better predictive inference.
To validate this hypothesis, we contrast Feature CP against the baseline with an unlearned neural network (whose feature is not semantic as desired).
We defer the results to Table 4 and related discussion to Appendix B.3.
Discussion.
We analyze the failure ( i.e. , inefficient) reasons of vanilla CP in image segmentation from two perspectives.
Firstly, this paper aims to provide provable coverage , namely, the confidence band should cover the ground truth for each pixel.
Since vanilla CP returns the same band for different samples, the loss is pretty large such that the returned interval is large enough to cover the ground truth.
Secondly, an intuitive explanation relates to our usage of ℓ ∞ to form the non-conformity score during the training.
We choose the infinity norm because reporting the total band length requires the band length in each dimension.
As a result, the non-conformity score is large as long as there exists one pixel that does not fit well, contributing to an unsatisfying band for vanilla CP.
We also conduct an ablation study to show that Feature CP is robust to the splitting point between f and g .
Under deep neural network regimes, we can split the model into f and g in a layer-level manner.
However, it still remains a problem how to choose the splitting point.
Fortunately, since the splitting is a hyperparameter, we can use standard cross validation to choose its value. Since the output space is one of the special feature layers, such techniques always generalize the scope of vanilla CP.
In Table 8 in Appendix, we show that the empirical coverage is robust to the splitting point.
Appendix
Section A provides the complete proofs, and Section B.1 provides experiment details.
A T HEORETICAL P ROOFS
We here show the complete proof of Theorem 5 in Section A.1, and show the proof of Theoremin Section A.2.
Theorem 4 and Theorem 5 shows the effectiveness (empirical coverage) and the efficiency (band length) in Feature CP.
We additionally provide Theorem 8 (see Section A.3) and Theorem 14 (see Section A.4) to better validate our theorem, in terms of the length variance and convergence rate.
A. P ROOF OF T HEOREM
Theorem 5 (Feature CP is provably more efficient) .
Assume that the non-conformity score is in norm-type.
For the operator H , we assume a Holder assumption that there exist α > 0 , L > 0 such that |H
( v, X ) − H ( u, X ) | ≤ L | v − u | α for all X .
Besides, we assume that there exists ϵ > 0 , c > 0 , such that the feature space satisfies the following cubic conditions:
Length Preserving.
Feature CP does not cost much loss in feature space in a quantile manner, namely, E D∼P n Q 1 − α
( H ( V f D , D )) <
E D∼P n Q 1 − α
( V o D )
+ ϵ . 2.
Expansion.
The operator H ( v, X ) expands the differences between individual length and their quantiles, namely, L E D∼P n M | Q 1 − α
( V f D ) − V f D | α < E D∼P n M [ Q 1 − α
( H ( V f D , D ))
− H ( V f D , D )] − ϵ − 2 max { L, 1 } ( c/ √ n ) min { α, 1 } .
Quantile Stability.
Given a calibration set D ca , the quantile of the band length is stable in both feature space and the output space, namely, E D∼P n | Q 1 − α ( V f D ) − Q 1 − α
( V f D ca )
| ≤ c √ n and E D∼P n | Q 1 − α ( V o D ) − Q 1 − α
( V o D ca )
| [Equation]
Then Feature CP provably outperforms vanilla CP in terms of average band length, namely,
[Equation] where the expectation is taken over the calibration fold and the testing point ( X ′ , Y ′ )
[Equation]
Proof of Theorem 5.
We start the proof with Assumption [Equation] which claims that
[Equation]
We rewrite it as
[Equation]
Due to Holder condition, we have that M H ( Q 1 − α
( V f D ) , D ) <
M ( H ( V f D , D ))
[Equation]
L M | Q 1 −
[Equation]
( V f D ) −
V f D | α , therefore
[Equation]
Therefore, due to assumption [Equation] we have that
[Equation]
[Table]
Besides, according to the quantile stability assumption, we have that E D | M H ( Q 1 − α
( V f D ) , D ) −
M H ( Q 1 − α ( V f D ) , D ) | ≤ L [ c/ √ n ] α , and E D | Q 1 − α
( V o D ) − Q 1 − α
( V o D )
| ≤ c/ √ n .
Therefore,
[Equation]
. A.1. E XAMPLE FOR T HEOREM
This section provides an example for Theorem 5.
The key information is that Feature CP loses less efficiency when conducting the quantile step.
Assume the dataset has five samples labeled A, B, C, D, and E. When directly applying vanilla
CP leads to individual length in the output space IL o as 1 , 2 , 3 , 4 , 5 , respectively.
By taking 80% quantile (namely, α = 0 . 2 ), the final confidence band returned by vanilla CP ( Q ( IL o )) would be
Q 0 .
= 4 .
Note that for any sample, the returned band length would be 4 , and the final average band length is 4 .
We next consider Feature CP.
We assume that the individual length in the feature space ( IL f ) is 1 . 1 , 1 . 2 , 1 . 1 , 1 . 3 , 1 . 6 , respectively.
Due to the expansion condition (cubic condition #2), the difference between IL f and Q ( IL f ) is smaller than that between IL o and Q ( IL o ) .
Therefore, the quantile step costs less in Feature CP.
Since IL f is close to Q ( IL f ) , their corresponding output length
H ( IL f ) , H ( Q ( IL f )) are also close.
Besides, to link conformal prediction and vanilla CP, the efficiency preserving condition (cubic condition #1) ensures that IL o is close to H ( IL f ) .
Therefore, the final average length M H ( Q ( L f )) is close to the average length M IL o , which is better than
Q ( IL o )
Finally, the quantile stability condition (cubic condition #3) generalizes the results from the calibration set to the test set.
A. P ROOF OF T HEOREM
Theorem 4 (theoretical guarantee for Feature CP) .
Under Assumption 1, for any α > 0 , the confidence band returned by Algorithm 3 satisfies:
[Equation]
where the probability is taken over the calibration fold and the testing point ( X ′ , Y ′ ) .
Proof of Theorem 4.
The key to the proof is to
For ease of notations, we denote the data points in the calibration fold and the test fold as D ′ =
{ ( X i , Y i ) } i ∈ [ m ] , where m denotes the number of data points in both calibration fold and test fold.
By Assumption 1, the data points in D ′ are exchangeable.
The proof can be split into three parts.
The first step is to show that for any function independent of D ′ , h ( X i , Y i ) are exchangeable.
The second step is to show that the proposed score function s satisfies the above requirements.
And the third step is to show the theoretical guarantee based on the exchangeability of the non-conformity score.
We next prove the first step: for any given function h : X × Y → R that is independent of data points in D ′ , we have that h ( X i , Y i ) are exchangeable.
Specifically, its CDF F v and its perturbation CDF
F πv is the same, given the training fold D tr .
[Equation]
| D tr
[Equation]
, where π denotes a random perturbation, and C h − 1 ( u − ) = { ( X, Y ) : h ( X, Y ) ≤ u } .
The second step is to show that the proposed non-conformity score function (See Equation (3) and
Algorithm 3) is independent of the dataset D ′ .
To show that, we note that the proposed score function s in Equation (3) (we rewrite it in Equation (5)) is totally independent of dataset D ′ , in that we only use the information of ˆ f and ˆ g which is dependent on the training fold D tr instead of D ′ .
[Equation]
Besides, note that when calculating the non-conformity score in Algorithm 3 for each testing data/calibration data, we do not access any information on the calibration folds for any other points.
Therefore, the score function does not depend on the calibration fold or test fold.
We finally remark that here we always state that the score function s does not depend on the calibration fold or test fold, but its realization s ( X, Y, ˆ g ◦ ˆ f ) can depend on the two folds, if ( X, Y ) ∈ D ′ .
This does not contrast with the requirement in the first step.
Therefore, combining the two steps leads to a conclusion that the non-conformity scores on D ′ are exchangeable.
Finally, following Lemma 1 in Tibshirani et al.
(2019), the theoretical guarantee holds under the exchangeability of non-conformity scores.
A. L ENGTH V ARIANCE G UARANTEE
The next Theorem 8 demonstrates that the length returned by Feature CP would be individually different.
Specifically, the variance for the length is lower bounded by a constant.
The essential intuition is that, for a non-linear function g , the feature bands with the same length return different bands in output space.
Before expressing the theorem, we first introduce a formal notation of length and other necessary assumptions.
For ease of discussion, we define in Definition 6 a type of band length slightly different from the previous analysis.
We assume Y ∈ R below, albeit our analysis can be directly extended to high-dimensional cases.
Definition 6 (band length) .
For a given feature v and any perturbation ˜ v ∈ C f ( v ) =
{ ˜ v : ∥
˜ v − v ∥ ≤
Q } in the feature band, we define the band length in the output space L o ( v ) as the maximum distance between predictor g ( v ) and g (˜ v ) , namely
[Equation]
Besides, we require Assumption 7, which is about the smoothness of the prediction head g .
Assumption 7.
Assume that the prediction head g is second order derivative and M -smooth, namely, ∥∇ 2 g ( u ) ∥
≤ M for all feasible u .
The following Theorem 8 indicates that the variance of the band length is lower bounded, meaning that the bands given by Feature CP are individually different.
Theorem 8.
Under Assumption 7, if the band on the feature space is with radius Q , then the variance of band length on the output space satisfies:
[Equation]
From Theorem 8, the variance of the band length has a non-vacuous lower bound if
[Equation]
We next discuss the condition for Equation (6).
For a linear function g , note that E [ ∥∇ g ( v ) ∥ − E ∥∇ g ( v ) ∥
= 0 and M = 0 , thus does not meet Equation (6).
But for any other non-linear function g , we at least have E [ ∥∇ g ( v ) ∥ − E ∥∇ g ( v ) ∥ ] 2 > 0 and M > 0 , and therefore there exists a term Q such that Equation (6) holds.
Hence, the band length in feature space must be individually different for a non-linear function g and a small band length Q .
Proof of Theorem 8.
We revisit the notation in the main text, where v = f ( X ) denotes the feature, and C f ( v ) =
{ ˜ v : ∥
˜ v − v ∥ ≤ Q } denotes the confidence band returned in feature space.
By Taylor
Expansion, for any given ˜ v ∈ C
f ( v ) , there exists a v ′ such that
[Equation]
Due to Assumption 7, ∥∇ 2 g ( v ′ )
∥ ≤ M .
Therefore, for any ˜ v ∈ C f ( v )
[Equation]
On the one hand, by Cauchy Schwarz inequality, we have
[Equation]
On the other hand, by setting ˜ v − v = Q ∇ g ( v ) / |∇ g ( v ) | , we have that
[Equation]
Therefore, we have that
[Equation]
We finally show the variance of the length, where the randomness is taken over the data v ,
[Equation]
Besides, note that E | [ |∇ g ( v ) | − E |∇ g ( v ) | ] | ≤ E |∇ g ( v ) | .
Therefore, we have that
E [ L o − E L o ] 2 /Q 2 ≥ E [ |∇ g ( v ) | − E |∇ g ( v ) | ] 2 − MQ E |∇ g ( v ) | .
A. T HEORETICAL C ONVERGENCE R ATE
In this section, we prove the theoretical convergence rate for the width.
Specifically, we derive that when the number of samples in the calibration fold goes to infinity, the width for the testing point converges to a fixed value.
Before we introduce the main theorem, we introduce some necessary definitions.
Without further clarification, we follow the notations in the main text.
Definition 9 (Precise Band) .
We define the precise band as
[Equation]
Definition 10 (Precise Exact Band) .
We define the exact precise band as
[Equation]
where ¯ Q 1 − α denotes the exact value such that
[Equation]
Our goal is to prove that the band length (volume) of C pre 1 − α (denoted by V ( C pre 1 − α ) ) converges to
V ( ¯ C pre 1 − α ) .
We assume that the prediction head and the quantile function are both Lipschitz in
Assumption 11 and Assumption 12.
Assumption 11 (Lipschitz for Prediction Head) .
Assume that for any v, v ′ , we have
[Equation]
Assumption 12 (Lipschitz for Inverse Quantile Function) .
Denote the quantile function as
Quantile (
[Equation]
We assume that its inverse function is L 2 -Lipschitz, that is to say,
[Equation]
Besides, we assume that the region of ¯ C pre 1 − α has benign blow-up.
Assumption 13 (Benign Blow-up) .
Assume that ¯ C pre 1 − α has benign blow-up, that is to say, for the blow-up set C pre 1 − α ( ϵ )
= { v : ∃ u ∈ ¯ C pre 1 − α , ∥ u − v ∥ ≤ ϵ } , we have
[Equation]
where c denotes a constant independent of n .
In the one-dimensional case Y ∈ R , Assumption 13 easily holds.
For the high-dimensional cases, such a bound usually requires that c depends on the dimension d .
Theorem 14 (Convergence Rate) .
Assume that the non-conformity scores in the calibration fold have no ties.
Under Assumption 11, Assumption 12 and Assumption 13, we have that
[Equation]
Proof.
Firstly, as derived in Romano et al.
(2019), when the non-conformity score in the calibration fold has no ties (the probability is zero), we have
[Equation]
where v, ˆ v, Q 1 − α denotes the surrogate feature, the trained feature, and the quantile value in Algorithm 3, respectively.
By Assumption 12 that the inverse quantile function is L 1 -Lipschitz around 1 − α , we have
[Equation]
Therefore, for any u ∈ C pre 1 − α , there exists u ′ ∈ ¯ C pre 1 − α such that
[Equation]
[Figure]
We note that bounding ∥ v − v ′ ∥ requires that the region of v, v ′ are both balls, and therefore one can select v ′ as the point with the smallest distance to v .
Since the region of ¯ C pre 1 − α has benign blow-up, we have that
[Equation]
Besides, the following equation naturally holds due to Equation (10).
[Equation]
Therefore, we conclude with the following inequality,
[Equation]
Therefore, as the sample size in the calibration fold goes to infinity, the length of the trained band converges to V ( ¯ C pre 1 − α ) .
B E XPERIMENTAL D ETAILS
Section B.1 introduces the omitted experimental details.
Section B.2 provide experimental evidence to validate cubic conditions.
Section B.3 shows that Feature CP performs similarly to vanilla CP for untrained neural networks, validating that Feature CP works due to semantic information trained in feature space.
Section B.4 introduces Feature CQR which applies feature-level techniques on
CQR and Section B.5 reports the corresponding group coverage.
Finally, Section B.6 provides other additional experiments omitted in the main text.
B.
E XPERIMENTAL D ETAILS
Model Architecture.
The model architecture of the uni-dimensional and synthetic multi-dimensional target regression task is shown in Figure 5.
The feature function f and prediction head g includes two linear layers, respectively.
Moreover, the model architecture of the FCN used in the semantic segmentation experiment is shown in Figure 6, which follows the official implementation of PyTorch.
The batch normalization and dropout layers are omitted in the figure.
We use the ResNet50 backbone as f and take two convolution layers as g .
We select the Layer4 output of ResNet50 as our surrogate feature v .
Training protocols.
In the unidimensional and synthetic dimensional target regression experiments, we randomly divide the dataset into training, calibration, and test sets with the proportion 2 : 2 : 1 .
As for the semantic segmentation experiment, because the labels of the pre-divided test set are not accessible, we re-split the training, calibration, and test sets randomly on the original training set of
[Figure]
Cityscapes.
We remove the class 0 (unlabeled) from the labels during calibration and testing, and use the weighted mean square error as the training objective where the class weights are adopted from
Paszke et al.
Randomness.
We train each model five times with different random seeds and report the mean and standard deviation value across all the runs as the experimental results (as shown in Figure 2 and
Table 1).
Details of transforming segmentation classification problem into a regression task.
The original semantic segmentation problem is to fit the one-hot label y whose size is ( C, W, H ) via logistic regression, where C is the number of the classes, W and H are the width and height of the image.
We use Gaussian Blur to smooth the values in each channel of y .
At this time, the smoothed label ˜
y ranges from 0 to 1.
Then, we use the double log trick to convert the label space from [0 , 1] to ( −∞ , ∞ ) , i.e. , ˙ y = log( − log(˜ y )) .
Finally, we use mean square error loss to fit ˙ y .
Definition of weighted length.
We formulate the weighted length as
[Equation]
where w ( j ) i is the corresponding weight in each dimension.
We remark that although the formulation of w ( j ) i is usually sample-dependent, we omit the dependency of the sample and denote it by w ( j ) when the context is clear.
We next show how to define w ( j ) in practice.
Generally speaking, we hope that w ( j ) is large when being informative ( i.e. , in non-boundary regions).
Therefore, for the j -th pixel after Gaussian Blur whose value is Y ( j ) ∈ [0 , 1] , its corresponding weight is defined as
[Equation]
| 2 Y ( j ) − 1 |
W ∈ [0 , 1] , where W = (cid:80) j | 2 Y ( j ) − 1 | is a scaling factor.
At a colloquial level, w ( j ) is close to 1 if Y ( j ) is close to 0 or 1 .
In this case, Y ( j ) being close to 0 or 1 means that the pixel is far from the boundary region.
Therefore, the weight indicates the degree to which a pixel is being informative (not in object boundary regions).
Calibration details.
During calibration, to get the best value for the number of steps M , we take a subset (one-fifth) of the calibration set as the additional validation set.
We calculate the nonconformity score on the rest of the calibration set with various values of step M and then evaluate on the validation set to get the best M whose coverage is just over 1 − α .
The final trained surrogate feature v is close to the true feature because ˆ g ( v ) is sufficiently close to the ground truth Y .
In practice, the surrogate feature after optimization satisfies ∥
ˆ g ( v ) − Y ∥
2 ∥ Y ∥< 1% .
B. C ERTIFYING C UBIC C ONDITIONS
In this section, we validate the cubic conditions.
The most important component for the cubic condition is Condition 2, which claims that conducting the quantile step would not hurt much efficiency.
We next provide experiment results in Table 3 on comparing the average distance
[Table] [Table]
between each sample to their quantile in feature space M | Q 1 − α V f D ca − V f D ca | and in output space
M [ Q 1 − α H ( V f D ca , D ca ) − H ( V f D ca , D ca )] .
We here take α = 1 for simplicity.
The significant gap in
Table 3 validates that the distance in feature space is significantly smaller than that in output space, although we did not consider the Lipschitz factor L for computational simplicity.
B. F EATURE CP WORKS DUE TO SEMANTIC INFORMATION IN FEATURE SPACE
Experiment results illustrate that feature-level techniques improve the efficiency of conformal prediction methods ( e.g. , Feature CP vs. CP, Feature CQR vs. CQR).
We claim that exploiting the semantic information in feature space is the key to our algorithm .
Different from most existing conformal prediction algorithms, which regard the base model as a black-box mode, feature-level operations allow seeing the training process via the trained feature.
This is novel and greatly broadens the scope of conformal prediction algorithms.
For a well-trained base model, feature-level techniques improve efficiency by utilizing the powerful feature embedding abilities of well-trained neural networks.
In contrast, if the base model is untrained with random initialization (whose representation space does not have semantic meaning), Feature CP returns a similar band length as the baseline (see Table 4).
This validates the hypothesis that Feature CP’s success lies in leveraging the inductive bias of deep representation learning.
Fortunately, realistic machine learning models usually contain meaningful information in the feature space, enabling Feature CP to perform well.
Ensure: C fcqr 1 − α
( X ) .
B. F EATURE C ONFORMALIZED Q UANTILE R EGRESSION
In this section, we show that feature-level techniques are pretty general in that they can be applied to most of the existing conformal prediction algorithms.
Specifically, We take Conformalized Quantile
Regression (CQR, Romano et al.
as an example and propose Feature-level Conformalized
Quantile Regression (Feature CQR).
The core idea is similar to Feature CP (See Algorithm 3), where we conduct calibration steps in the feature space.
We summarize the Feature CQR algorithm in
Algorithm 4.
Similar to CQR, Algorithm 4 also considers the one-dimension case where Y ∈ R .
We next discuss the steps in Algorithm 4.
Firstly, different from Feature CP, Feature CQR follows the idea of CQR that the non-conformity score can be negative (see Step 4).
Such negative scores help reduce the band length, which improves efficiency.
This is achieved by the index calculated in Step 5 3 .
Generally, if the predicted value is larger than the true value ˆ Y lo
i > Y
i , we need to adjust ˆ Y lo i to be smaller, and vice visa.
Step 8 follows the adjustment, where we summarize the criterion in Equation (12), given the two band [ C lo 0 , C lo 1 ] and [ C hi 0 , C hi 1 ] .
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
Similar to Feature CP, we need a Band Estimation step to approximate the band length used in
Step 6.
One can change it into Band Detection if necessary.
Different from Feature CP where Band
Estimation always returns the upper bound of the band, Feature CQR can only approximate it.
We conduct experiments to show that this approximation does not lose effectiveness since the coverage is always approximate to 1 − α .
Besides, different from CQR, which considers adjusting the upper and lower with the same value, we adjust them separately, which is more flexible in practice (see Step 7).
We summarize the experiments result in Table 6.
Feature CQR achieves better efficiency while maintaining effectiveness.
Here we provide 90% confidence band using five repeated experiments with different random seeds
[Table] [Table]
B. G ROUP COVERAGE FOR F EATURE C ONFORMALIZED Q UANTILE R EGRESSION
This section introduces the group coverage returned by feature-level techniques, which implies the performance conditional coverage, namely P ( Y ∈ C ( X ) | X ) .
Specifically, we split the test set into three groups according to their response values [Table] and report the minimum coverage over each group.
We remark that the group coverage of feature-level conformal prediction stems from its vanilla version.
That is to say, when the vanilla version has a satisfying group coverage, its feature-level version may also return a relatively satisfying group coverage.
Therefore, we did not provide Feature
CP here because vanilla CP cannot return a good group coverage.
We summarize the experiment results in Table 7.
Although we did not provide a theoretical guarantee for group coverage, Feature CQR still outperforms vanilla CQR in various datasets in terms of group coverage.
Among ten datasets, Feature CQR outperforms vanilla CQR in four datasets, and is comparable with vanilla CQR in five datasets.
Although the advantage is not universal, improving group coverage via feature-level techniques is still possible.
We note that there is still one dataset where vanilla CQR outperforms Feature CQR.
We attribute the possible failure reason of Feature CQR on the dataset FACEBOOK2 to the failure of base models.
As stated in Section B.3, Feature CQR only works when the base model is well-trained.
However, when grouping according to the returned values, it is possible that there exists one group that is not well-trained during the training process.
This may cause the failure of Feature CQR on the dataset
FACEBOOK2.
[Table]
[Figure]
B. A DDITIONAL E XPERIMENT R ESULTS
This section provides more experiment results omitted in the main text.
Distribution for non-conformity score in calibration fold.
We plot the distribution of calibration score in Figure 7.
We plot each non-conformity score in the calibration fold.
The distribution of non-conformity scores is smooth and single-peak in the real-world dataset, meaning that the proposed score is reasonable.
Ablation experiment on splitting point.
The ablation about the splitting point between f and g is in Table 8.
The ablation result shows that the coverage performance of our method is robust to the splitting method.
Visualization for the segmentation problem.
We also provide more visualization results for the segmentation problem in Figure 8.
C D ISCUSSION
We here plot the relationship between the efficiency (band length) v.s. cubic metric.
Specifically, cubic metric here represents the core statement in cubic condition (statement 2), which implies a metric form like M | Q 1 − α V f D ca − V f D ca | .
The results are shown in Figure 9.
[Table]
[Figure]