candle.uq_utils.compute_empirical_calibration_interpolation

candle.uq_utils.compute_empirical_calibration_interpolation#

candle.uq_utils.compute_empirical_calibration_interpolation(pSigma_cal, pPred_cal, true_cal, cv=10)#

Use the arrays provided to estimate an empirical mapping between standard deviation and absolute value of error, both of which have been observed during inference. Since most of the times the prediction statistics are very noisy, two smoothing steps (based on scipy’s savgol filter) are performed. Cubic Hermite splines (PchipInterpolator) are constructed for interpolation. This type of splines preserves the monotonicity in the interpolation data and does not overshoot if the data is not smooth. The overall process of constructing a spline to express the mapping from standard deviation to error is composed of smoothing- interpolation-smoothing-interpolation.

Parameters:
  • pSigma_cal (numpy array) – Part of the standard deviations array to use for calibration.

  • pPred_cal (numpy array) – Part of the predictions array to use for calibration.

  • true_cal (numpy array) – Part of the true (observed) values array to use for calibration.

  • cv (int) – Number of cross validations folds to run to determine a ‘good’ fit.

Returns:

Tuple of python objects

  • splineobj_best : scipy.interpolate python object A python object from scipy.interpolate that computes a cubic Hermite splines (PchipInterpolator) constructed to express the mapping from standard deviation to error after a ‘drastic’ smoothing of the predictions. A ‘good’ fit is determined by taking the spline for the fold that produces the smaller mean absolute error in testing data (not used for the smoothing / interpolation).

  • splineobj2 : scipy.interpolate python object A python object from scipy.interpolate that computes a cubic Hermite splines (PchipInterpolator) constructed to express the mapping from standard deviation to error. This spline is generated for interpolating the samples generated after the smoothing of the first interpolation spline (i.e. splineobj_best).