9
$\begingroup$

I have recently started learning about conformal prediction. I am a programmer without a strong mathematical background, but with a strong intuitive, applied background in statistics. I am trying to understand the intuition underlying conformal prediction and it is difficult to find good sources on this. Even the classic "A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification" quickly gets too mathematical for me to intuitively follow.

Could someone please give an intuitive explanation of the key concepts underlying conformal prediction with minimal mathematical details?

$\endgroup$
3
  • 1
    $\begingroup$ Are you interested in what it does or how it works (or both)? Also, see this excellent recent series. (The author now also has a book on the subject.) $\endgroup$
    – Eike P.
    Commented Mar 9, 2023 at 12:27
  • $\begingroup$ @EikeP., I am interested in both. Actually, I have just completed the series that you linked and it is because I am not fully satisfied that I am asking (and answering) this question. (I had to go through the email series twice to get a grasp on it.) As my answer below indicates, I am offering my answer to do a hopefully better job at answering the "what it does" question; I agree that that series is excellent for the intuition of "how it works". $\endgroup$
    – Tripartio
    Commented Mar 9, 2023 at 15:48
  • $\begingroup$ I think following these two tutorials from Swedish groups could be the'first contact' to conformal prediction. - Henric Linusen youtu.be/0MsGri8nmJQ - Ulf Johansson youtu.be/KsQpkjl7u1w $\endgroup$ Commented Jun 3, 2023 at 17:34

1 Answer 1

5
$\begingroup$

I am still learning, but let me present my current state of understanding. I was much helped by Christoph Molner's E-Mail Course On Conformal Prediction. I focus here entirely on the goals of the CP outcomes and completely skip how various CP algorithms might meet these goals. The intuition of the "how" is very important, but that varies with different algorithms, so there are many variations. I hope that other answers might fill in with that. For now, I find it much easier to understand the "how" if I first intuitively understand the "why", as I will attempt here.

The core idea is that instead of giving a single prediction for each row of data, a range of predictions is offered with a qualified guarantee that the true value will be within a specified range or set of options. For example, a 90% requirement guarantees that 90% of the true values will fall within the range or set given by the conformal prediction. The analyst can specify any required guarantee they want, such as 95% or 80% depending on their real-world application requirements. The

Let me give the basic idea of three kinds of conformal prediction: regression, binary classification, and multiclass classification.

Regression. Conformal prediction for regression is similar to prediction intervals for point predictions of the target variable (not to be confused with confidence intervals for coefficient estimates). However, prediction intervals have at least two limitations:

  • They assume a given distribution of the residuals, e.g., a normal distribution. In contrast, conformal prediction has no assumption about the distribution. It works for any model that produces predictions and works for any distribution of errors.
  • Even if distributional assumptions are met, there is no guarantee that new data will actually fall within the expected range. For example, a 90% prediction interval might result in 86% of actual values falling into the specified interval, or it might result in 93% in that interval. The 90% is just an approximation. In contrast, conformal prediction guarantees that for a 90% requirement, at least 90% of the data will fall within the interval that it specifies.

Binary classification. Conformal prediction for binary classification is best thought of as giving well-calibrated probability scores such that when all cases whose probabilities are above the requirement are combined, they are collectively guaranteed to meet the requirement. For example, if the requirement is 90%, then when considering new data, when all positive cases whose probabilities are > 90% are combined, then the conformal prediction guarantees that at least 90% of such cases are indeed positive.

Crucially, if the CP cannot guarantee either class (positive or negative) to be 90%, then it will predict both [positive, negative], which in CP terms means that the result is guaranteed to be one of the two. Since it would be too easy to achieve the guarantee by simply always predicting [positive, negative], two CP predictions that both meet the guarantee are compared by preferring the prediction that gives more single results (that is, either [positive] or [negative]) and fewer "any-of-the-above" results (that is, fewer [positive, negative]).

Multiclass classification. Conformal prediction for multiclass classification is best thought of as giving well-calibrated probability scores. However, rather than giving a single prediction of the most likely class, the result is a set of classes guaranteed to meet the requirement. For example, suppose that the requirement is that 90% of predictions will be correct and there are three classes A, B, and C. When considering new data, if the conformal prediction predicts any of the three classes (e.g., A) with certainty >= 90%, then its result will be that class with high certainty (i.e., [A]). But if none of its probabilities reaches the requirement, then the class probabilities will be cumulatively added and listed in order until the requirement is met. So, for example, if the calibrated probability for A is 70% and that for B is 23% (meaning that C is 7%), then the result will be [A, B], meaning that the true value is guaranteed to be either A or B, with 90% certainty. If no two probabilities meet the requirement (e.g., A = 70%, B = 18%, C = 12%), then the result will be all the options (i.e., [A, B, C]).

Again, as with CP for binary classification, to avoid the trivial case of achieving a guarantee by always predicting [A, B, C], the best CP algorithm is the one that has the lowest average set size. Understanding that all CP algorithms meet the required guarantee (e.g., 90% guaranteed), then a perfect CP algorithm would have an average size of 1 (that is, only one of the three classes is ever predicted, i.e. [A], [B], or [C]) and a useless CP algorithm would have an average size of 3 (that is, it always predicts [A, B, C], not necessarily in that order). Real-world CP algorithms will always have a value between 1 and 3, meaning that they very often give results with two values to meet the 90% requirement (e.g., [C, A] or [B, C]).

(Again, note that 90% is just an example; the analyst can specify any required guarantee they want, such as 95% or 80% depending on their real-world application requirements.)

Adaptive versus non-adaptive conformal prediction

There is at least one very important conceptual variation to note. By default, CP guarantees the requirement on average over all predicted data points. For example, if there are 100 lines of real data, suppose the predicted values could be split into a range of 10 data points each (you can think of this as 10 bins of a histogram). It is possible that for some ranges or bins, the guarantee is not met, but CP guarantees that it is met on average over all 10 bins. For example, maybe a 90% probability for the bins at the extreme ends only have 80% of positive cases (for binary classification) or have 80% of values that fall in the conformal interval (for regression), but for the middle bins, 95% of the values meet the guarantee, so the overall guarantee is indeed met when everything is averaged out. This default situation is called non-adaptive CP.

However, if we want every range of the data (that is, each of the 10 bins individually across the full range of predicted values) to meet the CP guarantee, then we need a CP algorithm that implements adaptive CP. In that case, not only do all the output data on average meet the CP guarantee, but every one of the 10 bins will individually also meet the CP guarantee. The point is that if we want to assure that the CP results adapt to different ranges of the data, then we must be sure that our chosen CP algorithm has this adaptive guarantee feature.

This is the core idea as I understand it. There are other forms (such as for time series analysis with sequentially ordered data), but that is beyond the scope of my intuitive primer.

$\endgroup$
6
  • $\begingroup$ As I indicate, I have found Christoph Molner's E-Mail Course On Conformal Prediction. very helpful, but it was not easy for me to understand because it begins with multiclass classification, skips binary classification, and then goes to regression. I personally had to rethink what I had read and I find that presenting regression first is more intuitive for me personally. $\endgroup$
    – Tripartio
    Commented Mar 9, 2023 at 15:50
  • $\begingroup$ @Troipartio, Thanks for the explanation. I am grappling with this idea too and for binary classification, there isn't any info as far as I could find. For binary classification, it doesn't seems to be providing much info (may be that's why Molner's book on CP starts with an example of 3 classes ). I was hoping to include CP in my work, but I think i will skip it for now. $\endgroup$
    – user62198
    Commented Aug 16, 2023 at 16:00
  • 1
    $\begingroup$ @user62198, you're right; there is very sparse information (and very few software packages) for binary classification. The only package I've found is an obsolete R package: github.com/isidroc/conformal. You could check out their documentation as they provide some fairly intuitive explanations of how they implement binary conformal prediction. $\endgroup$
    – Tripartio
    Commented Aug 17, 2023 at 9:39
  • 2
    $\begingroup$ There is a difference between a confidence interval (associated with estimating a parameter) and a prediction interval (associated with predicting a realization of a random variable). Could you perhaps update your answer trying to incorporate the appropriate terminology? E.g. consider updating this: Conformal prediction for regression is similar to confidence intervals for point predictions of the target variable (not to be confused with confidence intervals for coefficient estimates). $\endgroup$ Commented Oct 25, 2023 at 17:32
  • $\begingroup$ @RichardHardy Thanks; I have only recently become clearer on the difference between these two. I have revised my answer accordingly. $\endgroup$
    – Tripartio
    Commented Oct 25, 2023 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.