Skip to content

Commit

Permalink
Add recall precision curve example
Browse files Browse the repository at this point in the history
  • Loading branch information
titsuki committed Jul 25, 2020
1 parent 9a5d556 commit e4d29da
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
/gnuplot-*
/example/*
*.svg
*.png
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,60 @@ sin(x)

<img src="sinx.png" alt="sin(x)">

Recall-Precision Curve
----------------------

### SOURCE

use v6;
use Chart::Gnuplot;

my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("recprec.png"), :debug);
$gnu.title(:text("Recall-Precision Curve"));
$gnu.ylabel(:label("Precision"));
$gnu.xlabel(:label("Recall"));
$gnu.xrange(:min(0.0), :max(1.0));
$gnu.yrange(:min(0.0), :max(1.0));

my @methodA = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.9
0.3 0.85
0.4 0.82
0.5 0.6
0.6 0.55
0.7 0.51
0.8 0.4
0.9 0.38
1.0 0.35
EOF

my @methodB = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.8
0.3 0.5
0.4 0.4
0.5 0.3
0.6 0.2
0.7 0.1
0.8 0.08
0.9 0.05
1.0 0.05
EOF

my %methodA = %(:vertices(@methodA), :style("linespoints"), :title("proposed"), :lc(qw/rgb "green"/), :lt(10));
my %methodB = %(:vertices(@methodB), :style("linespoints"), :title("baseline"), :lc(qw/rgb "red"/), :lt(13));

$gnu.plot(|%methodA);
$gnu.plot(|%methodB);
$gnu.dispose;

### OUTPUT

<img src="recprec.png" alt="recall precision curve">

AUTHOR
======

Expand Down
57 changes: 57 additions & 0 deletions lib/Chart/Gnuplot.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,63 @@ Runs a given C<$command>. If there are no appropriate interfaces, this method wi
=end para
=head2 Recall-Precision Curve
=head3 SOURCE
use v6;
use Chart::Gnuplot;
my $gnu = Chart::Gnuplot.new(:terminal("png"), :filename("recprec.png"), :debug);
$gnu.title(:text("Recall-Precision Curve"));
$gnu.ylabel(:label("Precision"));
$gnu.xlabel(:label("Recall"));
$gnu.xrange(:min(0.0), :max(1.0));
$gnu.yrange(:min(0.0), :max(1.0));
my @methodA = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.9
0.3 0.85
0.4 0.82
0.5 0.6
0.6 0.55
0.7 0.51
0.8 0.4
0.9 0.38
1.0 0.35
EOF
my @methodB = (q:to/EOF/).split("\n", :skip-empty)>>.split(" ", :skip-empty);
0.0 1.0
0.1 0.95
0.2 0.8
0.3 0.5
0.4 0.4
0.5 0.3
0.6 0.2
0.7 0.1
0.8 0.08
0.9 0.05
1.0 0.05
EOF
my %methodA = %(:vertices(@methodA), :style("linespoints"), :title("proposed"), :lc(qw/rgb "green"/), :lt(10));
my %methodB = %(:vertices(@methodB), :style("linespoints"), :title("baseline"), :lc(qw/rgb "red"/), :lt(13));
$gnu.plot(|%methodA);
$gnu.plot(|%methodB);
$gnu.dispose;
=head3 OUTPUT
=begin para
<img src="recprec.png" alt="recall precision curve">
=end para
=head1 AUTHOR
titsuki <titsuki@cpan.org>
Expand Down
Binary file added recprec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e4d29da

Please sign in to comment.