def roc_auc_single(df, model): import sklearn.metrics as metrics num_label = {'ok': 1, 'nok' : 0} Y_test = df_test['class'].copy().map(num_label).astype('int') df.reset() predictions = model.predict(df, steps=len(df), verbose=0) pred_labels= np.where(predictions>0.5, 1, 0) roc_auc = metrics.roc_auc_score(Y_test, predictions) print('ROC_AUC: ', roc_auc) fpr, tpr, thresholds = metrics.roc_curve(Y_test, predictions) plt.plot(fpr, tpr, label = 'ROC_AUC = %0.3f' % roc_auc) plt.xlabel("False Positive Rate", fontsize= 12) plt.ylabel("True Positive Rate", fontsize= 12) plt.legend(loc="lower right") fig1 = plt.gcf() plt.show() plt.draw() fig1.savefig('roc_auc_single.png', dpi=50)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter