| 1 | ###*###################### -*- Mode: Perl -*- ######################### | ||
| 2 | ## | ||
| 3 | ## File : $RCSfile: EP_ND.pm,v $ | ||
| 4 | ## | ||
| 5 | ## Author : Norbert Gövert | ||
| 6 | ## Created On : Fri Nov 3 10:36:00 2000 | ||
| 7 | ## Last Modified : Time-stamp: <2000-11-09 18:27:05 goevert> | ||
| 8 | ## | ||
| 9 | ## Description : | ||
| 10 | ## | ||
| 11 | ## $Id: EP_ND.pm,v 1.6 2003/06/13 12:29:30 goevert Exp $ | ||
| 12 | ## | ||
| 13 | ###################################################################### | ||
| 14 | |||
| 15 | |||
| 16 | use strict; | ||
| 17 | |||
| 18 | |||
| 19 | =pod #---------------------------------------------------------------# | ||
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | RePrec::EP_ND - compute precision values | ||
| 24 | |||
| 25 | =head1 SYNOPSIS | ||
| 26 | |||
| 27 | (see RePrec(3)) | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | Computation of precision values according to the I<Expected Precision> | ||
| 32 | measure (user standpoint: stop at a given number of documents | ||
| 33 | retrieved). Equivalent to this measure is the I<Probability of | ||
| 34 | relevance (PRR)> measure with the same user standpoint. | ||
| 35 | |||
| 36 | =head1 METHODS | ||
| 37 | |||
| 38 | Mainly see RePrec(3). The precision function gives an unique | ||
| 39 | interpretation for each recall point. Precision can be computed for | ||
| 40 | each simple recall point only. | ||
| 41 | |||
| 42 | =cut #---------------------------------------------------------------# | ||
| 43 | |||
| 44 | |||
| 45 | package RePrec::EP_ND; | ||
| 46 | |||
| 47 | |||
| 48 | use base qw(RePrec); | ||
| 49 | |||
| 50 | |||
| 51 | our $VERSION; | ||
| 52 | '$Name: release_0_32 $ 0_0' =~ /(\d+)[-_](\d+)/; $VERSION = sprintf '%d.%03d', $1, $2; | ||
| 53 | |||
| 54 | |||
| 55 | ## public ############################################################ | ||
| 56 | |||
| 57 | sub precision { | ||
| 58 | |||
| 59 | my $self = shift; | ||
| 60 | my @recall = @_; | ||
| 61 | |||
| 62 | my @result; | ||
| 63 | |||
| 64 | foreach my $recall (sort @recall) { | ||
| 65 | |||
| 66 | return undef unless $recall and $recall > 0 and $recall <= 1; | ||
| 67 | |||
| 68 | # at which number of relevant documents do we stop? | ||
| 69 | my $NR = $recall * $self->{rels}; | ||
| 70 | |||
| 71 | # how many ranks do we have to examine? | ||
| 72 | my $NRint = int $NR; | ||
| 73 | $NRint++ if $NR > $NRint; | ||
| 74 | my $rank = $self->{rels_rank}->[$NRint - 1]; | ||
| 75 | #print STDERR "$rank $recall $NR $NRint\n"; | ||
| 76 | |||
| 77 | # number of relevant docs within the previous ranks | ||
| 78 | my $k = 0; | ||
| 79 | $k = $self->{rank_rels_nrels}->[$rank - 1]->[0] if $rank; | ||
| 80 | # number of non relevant docs within the previous ranks | ||
| 81 | my $j = 0; | ||
| 82 | $j = $self->{rank_rels_nrels}->[$rank - 1]->[1] if $rank; | ||
| 83 | # number of non relevant docs within the current rank | ||
| 84 | my $i = $self->{rank_rels_nrels}->[$rank]->[1] - $j; | ||
| 85 | # number of relevant docs which must be retrieved from the current rank | ||
| 86 | my $s = $NRint - $k; | ||
| 87 | # number of relevant docs within the current rank | ||
| 88 | my $r = $self->{rank_rels_nrels}->[$rank]->[0] - $k; | ||
| 89 | |||
| 90 | # do the PRR formula | ||
| 91 | push @result, [ $recall, $NR / ($NR + $j + $s * $i / $r) ]; | ||
| 92 | } | ||
| 93 | |||
| 94 | @result; | ||
| 95 | } | ||
| 96 | |||
| 97 | |||
| 98 | ## private ########################################################### | ||
| 99 | |||
| 100 | |||
| 101 | =pod #---------------------------------------------------------------# | ||
| 102 | |||
| 103 | =head1 BUGS | ||
| 104 | |||
| 105 | Yes. Please let me know! | ||
| 106 | |||
| 107 | =head1 SEE ALSO | ||
| 108 | |||
| 109 | RePrec(3), | ||
| 110 | perl(1). | ||
| 111 | |||
| 112 | =head1 AUTHOR | ||
| 113 | |||
| 114 | Norbert GE<ouml>vert E<lt>F<goevert@ls6.cs.uni-dortmund.de>E<gt> | ||
| 115 | |||
| 116 | =cut #---------------------------------------------------------------# | ||
| 117 | |||
| 118 | |||
| 119 | 1; | ||
| 120 | __END__ |