Function to transform confidence scores to logit #14186
-
I'm using YOLOv8 as a detector for audio. I transform audios to mel spectograms and I have sounds I want to detect (no classification needed, so unique class is set to True during training for the model) I want to create a logistic regression of the achieved output and I've read that it's better to do it with logits. As the output of YOLOv8 are confidence scores I would like to know if there is a recommended function to convert those confidence scores to logits in a post-processing step. SO, I already have the predictions of the BB with their scores, I just want to apply a function to those scores to transform them in logit score. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@GrunCrow hello, Thank you for your question! It's great to hear that you're using YOLOv8 for audio detection through mel spectrograms. To transform confidence scores to logits, you can use the logit function, which is the inverse of the sigmoid function. The logit function can be defined as: [ \text{logit}(p) = \log\left(\frac{p}{1-p}\right) ] Here's a simple Python function to convert confidence scores to logits: import numpy as np
def confidence_to_logit(confidence_scores):
# Ensure the confidence scores are within the valid range (0, 1)
confidence_scores = np.clip(confidence_scores, 1e-7, 1 - 1e-7)
logits = np.log(confidence_scores / (1 - confidence_scores))
return logits
# Example usage
confidence_scores = np.array([0.9, 0.8, 0.7])
logits = confidence_to_logit(confidence_scores)
print(logits) This function will take your confidence scores and convert them to logits, which you can then use for your logistic regression. Additionally, please ensure that you are using the latest version of the Ultralytics YOLO package to benefit from the latest features and bug fixes. If you encounter any issues, providing a minimum reproducible example can greatly help in diagnosing the problem. You can find more information on how to create one here: Minimum Reproducible Example. If you have any further questions or need additional assistance, feel free to ask. Happy coding! 😊 |
Beta Was this translation helpful? Give feedback.
-
@GrunCrow to convert confidence scores to logits, you can use the formula: |
Beta Was this translation helpful? Give feedback.
@GrunCrow to convert confidence scores to logits, you can use the formula:
logit = log(p / (1 - p))
, wherep
is the confidence score. This transformation can be applied in your post-processing step. Let me know if you need further assistance!