- CONFIGURATION AND ENVIRONMENT
- BUGS AND LIMITATIONS
- LICENSE AND COPYRIGHT
Calculate the Jaccard Similarity Coefficient.
Set::Jaccard::SimilarityCoefficient - Calculate the Jaccard Similarity Coefficient of 2 sets
$res = Set::Jaccard::SimilarityCoefficient::calc(\@set_a, \@set_b);
my $a = Set::Scalar->new(@set_a); my $b = Set::Scalar->new(@set_b); $res = Set::Jaccard::SimilarityCoefficient::calc($a, $b);
Set::Jaccard::SimilarityCoefficient lets you calculate the Jaccard Similarity Coefficient for either arrayrefs or Set::Scalar objects.
Briefly, the Jaccard Similarity Coefficient is a simple measure of how similar 2 sets are. The calculation is (in pseudo-code):
count(difference(SET-A, SET-B)) / count(union(SET-A, SET-B))
There is a Jaccard Similarity Coefficient routine already in CPAN, but it is specialized for use by Text::NSP. I wanted a generic routine that could be used by anyone so Set::Jaccard::SimilarityCoefficient was born.
calc(A, B) calculates the Jaccard Similarity Coefficient for the arguments A and B. A and B can be either array references or Set::Scalar objects.
new() will complain if A or B is empty, not either a reference to an array, or not a Set::Scalar object.
calc() could theoretically throw DivideByZeroException when the union of the two sets has 0 members. However, that would require set A or set B to have 0 members, which was previously prohibited by the prohibition on empty sets.
This module should work wherever Perl works.
None that I know of.
There are no bugs that I know of. Given that this is non-trivial code, there will be bugs.
The types of arguments are limited to either array references or Set::Scalar objects.
Mark Leighton Fisher, <firstname.lastname@example.org>
Set::JaccardSimilarityCoefficient is licensed under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 26:
Unknown directive: =function