puncc icon indicating copy to clipboard operation
puncc copied to clipboard

User friendly weight normalization

Open M-Mouhcine opened this issue 2 years ago • 2 comments

For simplicity, the weight normalization in case of nonexchangeable CP needs to be done inside the method deel.puncc.api.calibration.BaseCalibrator.calibrate.

Also, documentation should clarify if the weights passed as arguments are to be normalized or not.

M-Mouhcine avatar Sep 04 '23 11:09 M-Mouhcine

I have a question related to this issue. In the paper https://proceedings.mlr.press/v204/mendil23a/mendil23a.pdf, it is mentioned that Weighted Split Conformal Prediction (WSCP) can be implemented as follows:

# Definition of exponentially decaying weights function
def exp_decay(X):
    k = len(X)
    return [0.99 ** (k + 1 - i) for i in range(k)]

# Definition of split conformal predictor whose nonconformity scores
# are weighted according to the function defined above
wscp = SplitCP(predictor , weight_func = exp_decay)

I tried it out, but I always encounter an IndexError (sorted_cumsum_weights = np.cumsum(w[sorted_idx], axis=axis)) when I try to call wscp.predict(). Can you maybe provide a complete example that complements the one in the paper? Based on your above comment, one maybe has to work with the calibrator instead?

lubo93 avatar Jul 03 '25 18:07 lubo93

Ok, I just saw that there is an open pull request for a very helpful tutorial on time series CP (https://github.com/deel-ai/puncc/blob/mouhcine-ts-tutorial/docs/puncc_timeseries.ipynb). This is what I needed to better understand the weighting method.

lubo93 avatar Jul 04 '25 08:07 lubo93