def plot_roc_curve()

in builtin_algorithm_hpo_tabular/util/classification_report.py [0:0]


def plot_roc_curve(y_real,
                   y_predict,
                   axis=None,
                   plot_style='ggplot'):
    
    if axis is None:  # for standalone plot
        plt.figure()
        ax = plt.gca()
    else:  # for plots inside a subplot
        ax = axis
    
    plt.style.use(plot_style)
    
    metrics_FPR, metrics_TPR, _ = metrics.roc_curve(y_real, y_predict)
    metrics_AUC = metrics.roc_auc_score(y_real, y_predict)
    
    ax.set_aspect(aspect=0.95)
    ax.plot(metrics_FPR,
             metrics_TPR,
             color='b',
             linewidth=0.7)
    
    ax.fill_between(metrics_FPR,
                     metrics_TPR,
                     step='post',
                     alpha=0.2,
                     color='b')
    
    ax.plot([0, 1], [0, 1], color='k', linestyle='--', linewidth=1)
    ax.set_xlim([-0.05, 1.0])
    ax.set_ylim([0.0, 1.05])
    ax.set_xlabel('False Positive Rate')
    ax.set_ylabel('True Positive Rate')
    ax.set_title('ROC curve: AUC={0:0.3f}'.format(metrics_AUC))
    
    if axis is None:  # for standalone plots
        plt.tight_layout()
        plt.show()