{"id":104,"date":"2010-07-22T18:15:42","date_gmt":"2010-07-22T16:15:42","guid":{"rendered":"http:\/\/joernhees.de\/blog\/?p=104"},"modified":"2016-09-28T23:37:50","modified_gmt":"2016-09-28T21:37:50","slug":"precision-recall-diagrams-including-fmeasure","status":"publish","type":"post","link":"https:\/\/joernhees.de\/blog\/2010\/07\/22\/precision-recall-diagrams-including-fmeasure\/","title":{"rendered":"Precision-Recall diagrams including F-Measure height lines"},"content":{"rendered":"<p>Today I was asked how to generate <a href=\"http:\/\/en.wikipedia.org\/wiki\/Precision_and_recall\">Recall-Precision<\/a> diagrams including the f-measure values as height-lines from within python. Actually Gunnar was the one who had this idea <a href=\"http:\/\/gromgull.net\/blog\/2009\/06\/plotting-precision-and-recall-values\/\">quite a while ago<\/a>, but constantly writing things into files, then loading them with his R code to visualize them, made me create a &#8220;pythonified&#8221; version. Looks like this (click for large version):<br \/>\n<a href=\"https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2010\/07\/RecallPrecisionDiagram.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-105\" title=\"RecallPrecisionDiagram\" src=\"https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2010\/07\/RecallPrecisionDiagram-300x223.png\" alt=\"\" width=\"300\" height=\"223\" srcset=\"https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2010\/07\/RecallPrecisionDiagram-300x223.png 300w, https:\/\/joernhees.de\/blog\/wp-content\/uploads\/2010\/07\/RecallPrecisionDiagram.png 900w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nHere&#8217;s my python code-snippet for it: <a href=\"https:\/\/gist.github.com\/joernhees\/c58a4ca92faf3e4c5331\">recallPrecision.py<\/a>.<\/p>\n<style type=\"text\/css\">\n  .gist-data {max-height: 500px;}\n<\/style>\n<p>https:\/\/gist.github.com\/joernhees\/c58a4ca92faf3e4c5331<\/p>\n<p>Uses a bunch of pylab internally, but after simply importing this module, you can easily visualize a list of (precision, recall) points like this:<\/p>\n<pre><code class=\"python\">import scipy as sc\nimport pylab as pl\nimport recallPrecision as rp\nprs = sc.rand(15,2) # precision recall point list\nlabels = [\"item \" + str(i) for i in range(15)] # labels for the points\nrp.plotPrecisionRecallDiagram(\"footitle\", prs, labels)\npl.show()\n<\/code><\/pre>\n<p>(updated on 2014-10-28: link to gist)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I was asked how to generate Recall-Precision diagrams including the f-measure values as height-lines from within python. Actually Gunnar was the one who had this idea quite a while ago, but constantly writing things into files, then loading them with his R code to visualize them, made me create a &#8220;pythonified&#8221; version. Looks like [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[2],"tags":[35,48,122,125,131,132,140,183,188],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pYA5n-1G","jetpack-related-posts":[{"id":314,"url":"https:\/\/joernhees.de\/blog\/2010\/12\/15\/python-unicode-doctest-howto-in-a-doctest\/","url_meta":{"origin":104,"position":0},"title":"Python unicode doctest howto in a doctest","date":"2010-12-15","format":false,"excerpt":"Another thing which has been on my stack for quite a while has been a unicode doctest howto, as I remember I was quite lost when I first tried to test encoding stuff in a doctest. So I thought the ultimate way to show how to do this would be\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":166,"url":"https:\/\/joernhees.de\/blog\/2010\/07\/31\/urlencoding-in-python\/","url_meta":{"origin":104,"position":1},"title":"(URL)Encoding in python","date":"2010-07-31","format":false,"excerpt":"Well, encodings are a never ending story and whenever you don't want to waste time on them, it's for sure that you'll stumble over yet another tripwire. This time it is the encoding of URLs (note: even though related I'm not talking about the urlencode function). Perhaps you have seen\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":526,"url":"https:\/\/joernhees.de\/blog\/2013\/06\/08\/mac-os-x-10-8-scientific-python-with-homebrew\/","url_meta":{"origin":104,"position":2},"title":"Scientific Python on Mac OS X 10.8 with homebrew","date":"2013-06-08","format":false,"excerpt":"(newer version of this guide) A step-by-step installation guide to setup a scientific python environment based on Mac OS X and homebrew. Needless to say: Make a backup (Timemachine) First install homebrew. Follow their instructions, then come back here. If you don't have a clean install, some of the following\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":566,"url":"https:\/\/joernhees.de\/blog\/2014\/02\/25\/scientific-python-on-mac-os-x-10-9-with-homebrew\/","url_meta":{"origin":104,"position":3},"title":"Scientific Python on Mac OS X 10.9+ with homebrew","date":"2014-02-25","format":false,"excerpt":"Scientific python setup guide for Mac OS X 10.9 Mavericks with homebrew","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":19,"url":"https:\/\/joernhees.de\/blog\/2010\/06\/28\/python-and-encoding\/","url_meta":{"origin":104,"position":4},"title":"Python and encoding","date":"2010-06-28","format":false,"excerpt":"Well, first real post, so let's start easy. I've been working a lot with python lately, and came across a nice short How to Use UTF-8 with Python which also makes the difference between unicode and utf8 very clear. The howto also links to another valuable source: Characters vs. Bytes,\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":91,"url":"https:\/\/joernhees.de\/blog\/2010\/07\/21\/sort-python-dict-by-values\/","url_meta":{"origin":104,"position":5},"title":"Sort python dictionaries by values","date":"2010-07-21","format":false,"excerpt":"Perhaps you already encountered a problem like the following one yourself: You have a large list of items (let's say URIs for this example) and want to sum up how often they were viewed (or edited or... whatever). A small one-shot solution in python looks like the following and uses\u2026","rel":"","context":"In &quot;Coding&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/104"}],"collection":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":3,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/posts\/104\/revisions\/797"}],"wp:attachment":[{"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joernhees.de\/blog\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}