From 9ee1b4d4399798e98bd4f3ae1ceaf529bf0852bc Mon Sep 17 00:00:00 2001 From: Sachin Agarwal Date: Thu, 16 Feb 2017 02:43:33 +0530 Subject: [PATCH] plot iso-f1 curves in plot_precision_recall --- examples/model_selection/plot_precision_recall.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/model_selection/plot_precision_recall.py b/examples/model_selection/plot_precision_recall.py index f9244410d5792..c2e8cd7506cc6 100644 --- a/examples/model_selection/plot_precision_recall.py +++ b/examples/model_selection/plot_precision_recall.py @@ -127,6 +127,21 @@ average="micro") +# Plot ISO-F1 curve +plt.clf() +f_scores = np.linspace(0.1, 0.9, num=9) +for F in f_scores: + x = R = np.linspace(0.01, 1) + y = F * R / (2 * R - F) + plt.plot(x[y >= 0], y[y >= 0], color='navy') + plt.annotate('f1={0:0.1f}'.format(F), xy=(0.9, y[45] + 0.02)) +plt.xlabel('Recall') +plt.ylabel('Precision') +plt.xlim([0.0, 1.0]) +plt.ylim([0.0, 1.0]) +plt.title('ISO-F1 curves') +plt.show() + # Plot Precision-Recall curve plt.clf() plt.plot(recall[0], precision[0], lw=lw, color='navy',