1AI::Categorizer::ExperiUmseenrt(C3o)ntributed Perl DocumAeIn:t:aCtaitoengorizer::Experiment(3)
2
3
4

NAME

6       AI::Categorizer::Experiment - Coordinate experimental results
7

SYNOPSIS

9        use AI::Categorizer::Experiment;
10        my $e = new AI::Categorizer::Experiment(categories => \%categories);
11        my $l = AI::Categorizer::Learner->restore_state(...path...);
12
13        while (my $d = ... get document ...) {
14          my $h = $l->categorize($d); # A Hypothesis
15          $e->add_hypothesis($h, [map $_->name, $d->categories]);
16        }
17
18        print "Micro F1: ", $e->micro_F1, "\n"; # Access a single statistic
19        print $e->stats_table; # Show several stats in table form
20

DESCRIPTION

22       The "AI::Categorizer::Experiment" class helps you organize the results
23       of categorization experiments.  As you get lots of categorization
24       results (Hypotheses) back from the Learner, you can feed these results
25       to the Experiment class, along with the correct answers.  When all
26       results have been collected, you can get a report on accuracy,
27       precision, recall, F1, and so on, with both macro-averaging and micro-
28       averaging over categories.
29

METHODS

31       The general execution flow when using this class is to create an
32       Experiment object, add a bunch of Hypotheses to it, and then report on
33       the results.
34
35       Internally, "AI::Categorizer::Experiment" inherits from the
36       "Statistics::Contingency".  Please see the documentation of
37       "Statistics::Contingency" for a description of its interface.  All of
38       its methods are available here, with the following additions:
39
40       new( categories => \%categories )
41       new( categories => \@categories, verbose => 1, sig_figs => 2 )
42           Returns a new Experiment object.  A required "categories" parameter
43           specifies the names of all categories in the data set.  The
44           category names may be specified either the keys in a reference to a
45           hash, or as the entries in a reference to an array.
46
47           The "new()" method accepts a "verbose" parameter which will cause
48           some status/debugging information to be printed to "STDOUT" when
49           "verbose" is set to a true value.
50
51           A "sig_figs" indicates the number of significant figures that
52           should be used when showing the results in the "results_table()"
53           method.  It does not affect the other methods like
54           "micro_precision()".
55
56       add_result($assigned, $correct, $name)
57           Adds a new result to the experiment.  Please see the
58           "Statistics::Contingency" documentation for a description of this
59           method.
60
61       add_hypothesis($hypothesis, $correct_categories)
62           Adds a new result to the experiment.  The first argument is a
63           "AI::Categorizer::Hypothesis" object such as one generated by a
64           Learner's "categorize()" method.  The list of correct categories
65           can be given as an array of category names (strings), as a hash
66           whose keys are the category names and whose values are anything
67           logically true, or as a single string if there is only one
68           category.  For example, all of the following are legal:
69
70            $e->add_hypothesis($h, "sports");
71            $e->add_hypothesis($h, ["sports", "finance"]);
72            $e->add_hypothesis($h, {sports => 1, finance => 1});
73

AUTHOR

75       Ken Williams <ken@mathforum.org>
76
78       This distribution is free software; you can redistribute it and/or
79       modify it under the same terms as Perl itself.  These terms apply to
80       every file in the distribution - if you have questions, please contact
81       the author.
82
83
84
85perl v5.30.1                      2020-01-29    AI::Categorizer::Experiment(3)
Impressum