I'm new on this, but I'd like to plot a ROC curve for a small dataset of active compounds versus decoys. I based myself on this link: ROC curve for binary classification in python In this case, this small dataset is a result of a virtual screening that ranked and scored the compounds with known activity or inactivity from experimental data (IC50).
I'm not sure if the plot and the AUC are correct. I noticed that even if there was only one-value difference between the test (true) predicted values, the AUC was only 0.5. For the true and predicted values in the code I inserted below, it was around 0.49 only. Perhaps the model was not properly identifying the compounds. However, I noticed that for the first ten compounds in the rank, it identified correctly, besides some in other positions. Maybe it better identified active compounds than negative ones, or maybe it was because there were more active compounds to be considered. Also, would it be better to use another classification system for the tested and predicted values, other than a binary classification? For example, ranking the IC50 values from best to worst and comparing with the virtual screening rank, creating a score for the true and predicted results, considering the similarity between the ranks of each compound (for IC50 and virtual screening)?
I also thought in doing a precision-recall curve, considering the data imbalance between the quantity of active compounds and decoys.
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve, auc, roc_auc_score
test = [1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1]
pred = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0]
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(2):
fpr[i], tpr[i], _ = roc_curve(test, pred)
roc_auc[i] = auc(fpr[i], tpr[i])
print(roc_auc_score(test, pred))
plt.figure()
plt.plot(fpr[1], tpr[1])
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.show()