Zhendong-Wang / Probabilistic-Conformal-Prediction

Official Python implementation for paper: Probabilistic Conformal Prediction Using Conditional Random Samples
MIT License
10 stars 3 forks source link

Extending PCP to model agnostic framework AND "interval = union([(s - self.qt, s + self.qt) for s in pred_te])" ??? #1

Open CoteDave opened 10 months ago

CoteDave commented 10 months ago

Hi Zhendong,

I tried to adapt your amazing PCP framework to a model agnostic PCP-framework, --> SLCP-PCP.

To do this, I replaced your QRF-PCP framework (uniform) with a nonconformis agnostic wrapper (Split Localized Comformal Predictions - https://github.com/aaronhan223/SLCP) to get conformal prediction intervals with any model using the CQR error function "QuantileRegAsymmetricErrFunc".

So instead of using the quantiles predicted by a QRF model as input to your PCP, I use the conformal prediction intervals CQR (alpha, 1-alpha) from the agnostic SLCP wrapper, so I can put any sklearn-like model in the final framework SLCP-PCP.

My first question: Is this experimental approach make sens to you ? (seems to give me better and narrower prediction intervals with SLCP-PCP than with just SLCP... )

My second question, in your .predict() function of your PCP class, you predict "bands": def predict(self, X): [...] bands = [] for pred_te in tqdm(preds_te): interval = union([(s - self.qt, s + self.qt) for s in pred_te]) bands.append(interval)

if I just want to return mean, low(alpha), high(1-alpha) for each row. how can I transform the results in bands to ge that ? It returns a list of length X but with n columns that I don't really understand the meaning... what exactly is returning "interval = union([(s - self.qt, s + self.qt) for s in pred_te])" ?

Thanks !

Zhendong-Wang commented 10 months ago

Hi there, thanks for your interest in PCP paper. PCP is agnostic to the model choice, as we tested different machine learning models as our model backbones. So I think using SLCP as long as it is a prection model, it will work.

PCP is probabilistic conformal prediction, and it predict bands, which is a set of conformal prediction intervals, so as it can easily capture multi modes if the distribution is complex. The union will return the union of each small intervals, which is a list of intervals.

Hope this helps!