ALBD

 view release on metacpan or  search on metacpan

lib/LiteratureBasedDiscovery/Evaluation.pm  view on Meta::CPAN


# Timeslicing evaluation that calculates the precision of LBD 
# (O(k), where k is the number of keys in results)
# input: $resultsMatrixRef <- ref a matrix of LBD results
#        $goldMatrixRef <- ref to a gold standard matrix
# output: the precision of results
sub calculatePrecision {
    my $resultsMatrixRef = shift;
    my $goldMatrixRef = shift;

    # calculate the precision which is the percentage of results that are 
    # are in the gold standard
    # (percent of generated that is gold)
    my $count = 0;
    foreach my $key(keys %{$resultsMatrixRef}) {
	if (exists ${$goldMatrixRef}{$key}) {
	    $count++;
	}
    }
    return $count/(scalar keys %{$resultsMatrixRef});

}

# Timeslicing evaluation that calculate the recall of LBD 
# (O(k), where k (is the number of keys in gold)
# input: $resultsMatrixRef <- ref a matrix of LBD results
#        $goldMatrixRef <- ref to a gold standard matrix
# output: the recall of results
sub calculateRecall {
    my $resultsMatrixRef = shift;
    my $goldMatrixRef = shift;
    
    # calculate the recall which is the percentage of knowledge in the gold
    # standard that was generated by the LBD system 
    # (percent of gold that is generated)
    my $count = 0;
    foreach my $key(keys %{$goldMatrixRef}) {
	if (exists ${$resultsMatrixRef}{$key}) {
	    $count++;
	}
    }
    return $count/(scalar keys %{$goldMatrixRef});
}

1;



( run in 0.415 second using v1.01-cache-2.11-cpan-05162d3a2b1 )