You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
Hi Glenn , after i run your code still the roc is not good . I tried to use detection confidence maybe that was the problem but nothing the roc is nan. I put the code you gave to me and mayde you can help me again. All the classes are 0 i am using only one. And the last culunm is the confidence one. I am not using ground truth labels only the confidence score. Can you help with modifying for ground truth if it's needs.Thank you
Additional
`import pandas as pd
from sklearn.metrics import roc_curve, auc
import matplotlib.pyplot as plt
import glob
This will hold all your scores and true values
all_scores = []
y_true = []
Loop through all CSV files in your directory
for csv_file in glob.glob('labelsval1/*.csv'):
data = pd.read_csv(csv_file, header=None)
scores = data[1].tolist()
all_scores.extend(scores)
# Ensure to update y_true based on your actual data specifics, using 0 or 1 accordingly.
y_true.extend([class_label] * len(scores)) # Replace class_label with 0 or 1 as appropriate.
Hello! 🚀 It looks like you're experiencing issues with generating the ROC curve because you're not using ground truth labels.
To properly calculate AUC for ROC, you will need the actual labels (ground truth) for each prediction to compare against. It seems you only have the detection confidence scores.
Here’s a method to modify your script to include ground truth labels:
Update the y_true list in your loop to include actual labels from your dataset.
Map your class labels to 0 or 1 based on the detection (presence or absence of your target class).
Modify this part of your script:
# Assume your actual labels column in CSV is the second column (index 1)labels=data[1].tolist() # adjust index based on your data structure
...
y_true.extend(labels)
Ensure you're reading from the correct column index for labels and scores in your CSV. After this adjustment, the ROC calculation should function with accurate class labels.
Search before asking
Question
Hi Glenn , after i run your code still the roc is not good . I tried to use detection confidence maybe that was the problem but nothing the roc is nan. I put the code you gave to me and mayde you can help me again. All the classes are 0 i am using only one. And the last culunm is the confidence one. I am not using ground truth labels only the confidence score. Can you help with modifying for ground truth if it's needs.Thank you
Additional
`import pandas as pd
from sklearn.metrics import roc_curve, auc
import matplotlib.pyplot as plt
import glob
This will hold all your scores and true values
all_scores = []
y_true = []
Loop through all CSV files in your directory
for csv_file in glob.glob('labelsval1/*.csv'):
data = pd.read_csv(csv_file, header=None)
scores = data[1].tolist()
all_scores.extend(scores)
# Ensure to update y_true based on your actual data specifics, using 0 or 1 accordingly.
y_true.extend([class_label] * len(scores)) # Replace class_label with 0 or 1 as appropriate.
Calculate ROC
fpr, tpr, thresholds = roc_curve(y_true, all_scores)
roc_auc = auc(fpr, tpr)
Plotting
plt.figure()
plt.plot(fpr, tpr, color='darkorange', lw=2, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver Operating Characteristic')
plt.legend(loc="lower right")
plt.show()`
The text was updated successfully, but these errors were encountered: