0

I'm working the following plot:

enter image description here

For wich I'm using the following code:

testy = [0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1]


probs = [0. , 1. , 1. , 0. , 0. , 0.9, 0. , 0. , 0. , 0.1, 1. , 0. , 0. ,
       0.9, 1. , 0. , 1. , 1. , 0. , 0. , 1. , 1. , 0. , 0. , 0.1, 1. ,
       0. , 0. , 0.9, 0. , 0.9, 0. , 1. , 0. , 0. , 0. , 1. , 0. , 1. ,
       0. , 0. , 0. , 0.9, 0. , 1. ]

def plot_roc_curve(testy, probs,data_dir=''):
    fpr, tpr, thresholds = roc_curve(testy, probs)    
    fig, ax = plt.subplots()
    ax.plot(fpr*100, tpr*100, color='black', marker='.')
    ax.plot([0, 100], [0, 100], color='darkblue', linestyle='--')
    ax.set_title('ROC Curve',fontweight='bold',loc='left')
    ax.set_xlabel('False Positive Rate',fontweight='bold')
    ax.set_ylabel('True Positive Rate',fontweight='bold')





plot_roc_curve(testy, probs,data_dir='')

I want to modify the plot to add the '%' symbol as 80%, 100%...

for that, I have the following code:

def plot_roc_curve(testy, probs,data_dir=''):
    fpr, tpr, thresholds = roc_curve(testy, probs)

    fig, ax = plt.subplots()
    ax.plot(fpr*100, tpr*100, color='black', marker='.')
    ax.plot([0, 100], [0, 100], color='darkblue', linestyle='--')
    ax.set_title('ROC Curve',fontweight='bold',loc='left')
    ax.set_yticklabels(['{:,.2%}'.format(x) for x in fpr])
    ax.set_xticklabels(['{:,.2%}'.format(x) for x in fpr])
    ax.set_xlabel('False Positive Rate',fontweight='bold')
    ax.set_ylabel('True Positive Rate',fontweight='bold')


plot_roc_curve(testy, probs)

But this breaks the code, since the label does not match the points:

enter image description here

Luis Ramon Ramirez Rodriguez
  • 9,591
  • 27
  • 102
  • 181

0 Answers0