Skip to content

Roc curve /part 2 #13022

Closed
Closed
@gchinta1

Description

@gchinta1

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
image
image

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()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions