Conformal Prediction: A Critic to Predictive Models

Data Overload
9 min readJan 3, 2023

--

I have posted about some machine learning models to make predictions, but now, we should ask ourselves this: do we need a certainty?

This story was written with the assistance of an AI writing program.

Photo by ian dooley on Unsplash

Conformal prediction is a statistical method for making predictions about a future observation, while also providing a measure of the uncertainty associated with that prediction. It is based on the idea of “nonconformity,” which is a measure of how well an observation fits with a given statistical model. Conformal prediction algorithms use this measure of nonconformity to construct prediction intervals, which are intervals that have a high probability of containing the future observation, given the available data. These prediction intervals can be used to make predictions that are more reliable and more informative than those obtained using traditional statistical methods, because they not only provide a point estimate of the predicted value, but also a measure of the uncertainty associated with that estimate.

Conformal prediction is important because it allows you to make predictions that are more reliable and more informative than those obtained using traditional statistical methods. Traditional statistical methods, such as maximum likelihood estimation, often rely on assumptions about the underlying data distribution, which may not hold in practice. As a result, the predictions made using these methods may be overly optimistic, and may not accurately reflect the uncertainty associated with the prediction.

Conformal prediction, on the other hand, does not make any assumptions about the underlying data distribution, and instead directly estimates the uncertainty associated with the prediction using the available data. This can be particularly useful in situations where the data is complex, or where the data distribution is not well understood. By providing a measure of the uncertainty associated with a prediction, conformal prediction can help you to make more informed decisions, and to better understand the risks and limitations of your predictions.

Traditional statistical methods, such as maximum likelihood estimation, often rely on assumptions about the data distribution, such as normality or homoscedasticity. These assumptions may not hold in practice, and can lead to overly optimistic predictions that do not accurately reflect the uncertainty associated with the prediction.

Conformal prediction, on the other hand, does not make any assumptions about the data distribution, and instead directly estimates the uncertainty associated with the prediction using the available data. This can be particularly useful in situations where the data is complex, or where the data distribution is not well understood. By providing a measure of the uncertainty associated with a prediction, conformal prediction can help you to make more informed decisions, and to better understand the risks and limitations of your predictions.

There are several steps involved in applying conformal prediction:

  1. First, you need to choose a statistical model that you will use to make predictions. This could be a simple linear regression model, a more complex machine learning model, or any other type of statistical model.
  2. Next, you need to split your data into two sets: a training set, which will be used to fit the statistical model, and a test set, which will be used to evaluate the model’s performance.
  3. Fit the statistical model to the training data, and use it to make predictions for the test set.
  4. Use a conformal prediction algorithm to construct prediction intervals for each of the predictions made in step 3. These prediction intervals will have a high probability of containing the true value of the prediction, given the available data.
  5. Evaluate the performance of the prediction intervals by comparing them to the true values in the test set. This can be done using a variety of metrics, such as the coverage rate (i.e., the percentage of true values that fall within the prediction intervals) or the length of the intervals.
  6. If the performance of the prediction intervals is satisfactory, you can use the fitted statistical model and the conformal prediction algorithm to make predictions for new, unseen data.

There are also some potential disadvantages to consider when using conformal prediction:

  1. It may not be as efficient as traditional statistical methods, in the sense that it may require more data to achieve the same level of accuracy.
  2. It may not be suitable for situations where the data is highly skewed or has a heavy-tailed distribution, as the prediction intervals may be overly conservative in these cases.
  3. It may not perform well when the number of features is very large, as the computation time for constructing the prediction intervals can become very large.
  4. It may not be suitable for situations where the prediction intervals need to be very narrow, as the prediction intervals produced by conformal prediction algorithms tend to be somewhat wider than those produced by traditional statistical methods.

Interpretation of the Results

There are several metrics that can be used to evaluate the performance of conformal prediction:

  1. Coverage rate: The coverage rate is the percentage of true values that fall within the prediction intervals. A coverage rate of approximately the nominal level (usually 95%) is desired.
  2. Length of the intervals: The length of the intervals is a measure of the uncertainty associated with the prediction. Shorter intervals indicate more precise predictions, while longer intervals indicate more uncertain predictions.
  3. Mean interval width: It is the average width of the intervals, which is related to the length of the intervals.
  4. Average relative width: It is the ratio of the mean interval width to the mean of the observations.
  5. Mean interval score: It is a measure of the accuracy of the intervals, defined as the average of the ratio of the length of the interval to the true value.
  6. Average Nonconformity measure: A measure of how well a data point fits with the model, can also be used to evaluate the performance of conformal prediction.
  7. P-value: It is the probability of obtaining an interval that covers the true value, given the available data and the model used.

To interpret the results of conformal prediction, it’s important to keep in mind that the goal is to have a coverage rate that is close to the nominal level (usually 95%) and intervals that are not too wide or too narrow. A coverage rate that is too high or too low, or intervals that are too wide or too narrow, can indicate a problem with the model or the data.

It’s also important to consider the specific application and the desired level of uncertainty. For example, in some applications, such as medical diagnostics, a higher level of certainty may be desired, while in others, such as financial forecasting, a higher level of uncertainty may be acceptable.

Evaluating and interpreting the results of conformal prediction require a good understanding of the problem, the data, and the model used. It’s always a good idea to try different models, and compare the results using different metrics to find the best option for a particular problem.

Applications

Conformal prediction has a wide range of applications, and has been used in many different fields, including:

  • Machine learning and data mining: Conformal prediction has been used to improve the performance and reliability of machine learning algorithms, particularly in situations where the data is complex or the data distribution is not well understood. For example, in NLP conformal prediction can be used to predict the likelihood of a text being spam, or the likelihood of a tweet spreading misinformation by providing prediction intervals for each text.
  • Finance: Conformal prediction has been used in the financial industry to make more reliable and informative predictions about stock prices and other financial variables. By providing prediction intervals, conformal prediction can help investors make more informed decisions and better understand the risks associated with their investments. If you are interested in stock price prediction, check out my post below! Another example could be fraud detection. Conformal prediction can be used in fraud detection by predicting the likelihood of a financial transaction being fraudulent based on its characteristics. By providing prediction intervals, conformal prediction can help financial institutions make more informed decisions about which transactions to flag as potentially fraudulent.
  • Medicine: Conformal prediction has been used in medical research to make more reliable and informative predictions about treatment outcomes, and to better understand the risks and benefits of different treatment options. For example, conformal prediction can be used to predict the likelihood of a patient having a certain disease based on their symptoms and test results. By providing prediction intervals, conformal prediction can help doctors make more informed decisions and avoid false positives or false negatives.
Photo by Online Marketing on Unsplash
  • Environmental science: Conformal prediction has been used in environmental science to make more reliable and informative predictions about environmental variables, such as temperature, precipitation, and atmospheric carbon dioxide concentrations. For example, in climate science, conformal prediction can be used to predict the likelihood of certain weather events, such as hurricanes or droughts. By providing prediction intervals, conformal prediction can help meteorologists make more informed predictions and better understand the risks associated with certain weather patterns.
  • Sports: Conformal prediction has been used in the sports industry to make more reliable and informative predictions about the outcomes of sporting events, such as soccer matches and tennis tournaments.
Photo by John Fornander on Unsplash
  • Marketing: Conformal prediction has been used in marketing research to make more reliable and informative predictions about consumer behavior, such as which products or services consumers are most likely to purchase.
  • Many other fields: Conformal prediction has also been applied in many other fields, including biology, chemistry, engineering, and social science.

Comparison to Other Methods

Conformal prediction is a method of uncertainty estimation that is based on the idea of “nonconformity,” which is a measure of how well an observation fits with a given statistical model. Conformal prediction algorithms use this measure of nonconformity to construct prediction intervals, which are intervals that have a high probability of containing the future observation, given the available data.

Bayesian methods, on the other hand, are a class of statistical methods that are based on Bayes’ theorem, which describes the probability of an event occurring based on prior knowledge of conditions that might be related to the event. Bayesian methods typically involve specifying a prior distribution over the parameters of the model, and then using the data to update this prior distribution to a posterior distribution. This posterior distribution is then used to make predictions and estimate uncertainty.

Bootstrapping is a resampling method that is used to estimate the uncertainty of a given statistic or estimate. Bootstrapping involves repeatedly drawing samples with replacement from the original data set, and then calculating the statistic of interest for each sample. The distribution of the calculated statistic is then used to estimate the uncertainty of the original estimate.

Each method has its own advantages and disadvantages. Conformal prediction is particularly useful when the data distribution is not well understood, or when the data is complex, as it does not make any assumptions about the underlying data distribution. Bayesian methods are useful when prior knowledge about the data is available, and when the assumptions about the data distribution are reasonable. Bootstrapping is a simple and widely used method, which does not rely on any assumptions about the data distribution, but it’s not suitable for certain types of data or models.

In general, conformal prediction is most appropriate when the assumptions made by Bayesian methods do not hold and when you don’t have any prior knowledge about the data and its distribution. Bootstrapping is most appropriate when you have a limited amount of data and want to estimate uncertainty without making any assumptions about the data distribution. Bayesian methods are most appropriate when prior knowledge of the data is available and when the assumptions made are reasonable.

It’s important to note that the choice of method depends on the specific problem and the available data, and it’s always a good idea to try different methods and compare their results to find the best option for a particular problem.

--

--

Data Overload

Data Science | Finance | Python | Econometrics | Sports Analytics | Lifelong Learner