EFS-OpenSource / calibration-framework

The net:cal calibration framework is a Python 3 library for measuring and mitigating miscalibration of uncertainty estimates, e.g., by a neural network.
https://efs-opensource.github.io/calibration-framework/
Apache License 2.0
344 stars 42 forks source link

Information on relative_x_position variable #15

Closed manueltonneau closed 3 years ago

manueltonneau commented 3 years ago

Hi and thanks for this great repo,

I'm trying to use the repo to calibrate the confidence scores from a BERT model I fine-tuned. My problem is a binary classification and I want to use Platt Scaling (LogisticCalibration class). I am not sure I understand what the relative_x_position variable refers to? Could you please help me understand this?

Thanks a lot in advance.

fabiankueppers commented 3 years ago

Hi @manueltonneau, thanks for using my repository. Currently, I'm not sure where to find your relative_x_position variable in this framework. Is it a variable of your code? Basically, you can pass any additional information in conjunction with the confidence information to a calibration mapping. For instance, if you have a NumPy array with confidence estimates of shape (N,) and a second array with the according relative x positions of the same shape, you can stack them by "np.stack((confidence, relative_x_position), axis=1) to get an array of shape (N, 2) that can be passed to the calibrator. However, you must also set the flag "detection=True" in the constructor of LogisticCalibration.

I hope I was able to help you.

fabiankueppers commented 3 years ago

My fault, I finally found the variable in my readme ;) If you only have a straight-forward binary classification problem without any additional information, you can simply skip the "relative_x_position" variable. Simply pass the confidence array to the calibration algorithm. Hope this helps!

trathpai commented 2 years ago

@fabiankueppers What does this variable exactly mean for the detection case? center_x position of bounding box relative to the width of image? What about center_y_position ? Is it not required or used for calibration?

Thank you in anticipation!