1AI::Categorizer::HypothUesseirs(C3o)ntributed Perl DocumAeIn:t:aCtaitoengorizer::Hypothesis(3)
2
3
4

NAME

6       AI::Categorizer::Hypothesis - Embodies a set of category assignments
7

SYNOPSIS

9        use AI::Categorizer::Hypothesis;
10
11        # Hypotheses are usually created by the Learner's categorize() method.
12        # (assume here that $learner and $document have been created elsewhere)
13        my $h = $learner->categorize($document);
14
15        print "Assigned categories: ", join ', ', $h->categories, "\n";
16        print "Best category: ", $h->best_category, "\n";
17        print "Assigned scores: ", join ', ', $h->scores( $h->categories ), "\n";
18        print "Chosen from: ", join ', ', $h->all_categories, "\n";
19        print +($h->in_category('geometry') ? '' : 'not '), "assigned to geometry\n";
20

DESCRIPTION

22       A Hypothesis embodies a set of category assignments that a categorizer
23       makes about a single document.  Because one may be interested in
24       knowing different kinds of things about the assignments (for instance,
25       what categories were assigned, which category had the highest score,
26       whether a particular category was assigned), we provide a simple class
27       to help facilitate these scenarios.
28

METHODS

30       new(%parameters)
31           Returns a new Hypothesis object.  Generally a user of
32           "AI::Categorize" doesn't create a Hypothesis object directly - they
33           are returned by the Learner's categorize() method.  However, if you
34           wish to create a Hypothesis directly (maybe passing it some fake
35           data for testing purposes) you may do so using the new() method.
36
37           The following parameters are accepted when creating a new
38           Hypothesis:
39
40           all_categories
41               A required parameter which gives the set of all categories that
42               could possibly be assigned to.  The categories should be
43               specified as a reference to an array of category names (as
44               strings).
45
46           scores
47               A hash reference indicating the assignment score for each
48               category.  Any score higher than the "threshold" will be
49               considered to be assigned.
50
51           threshold
52               A number controlling which categories should be assigned - any
53               category whose score is greater than or equal to "threshold"
54               will be assigned, any category whose score is lower than
55               "threshold" will not be assigned.
56
57           document_name
58               An optional string parameter indicating the name of the
59               document about which this hypothesis was made.
60
61       categories()
62           Returns an ordered list of the categories the document was placed
63           in, with best matches first.  Categories are returned by their
64           string names.
65
66       best_category()
67           Returns the name of the category with the highest score in this
68           hypothesis.  Bear in mind that this category may not actually be
69           assigned if no categories' scores exceed the threshold.
70
71       in_category($name)
72           Returns true or false depending on whether the document was placed
73           in the given category.
74
75       scores(@names)
76           Returns a list of result scores for the given categories.  Since
77           the interface is still changing, and since different Learners
78           implement scoring in different ways, not very much can officially
79           be said about the scores, except that a good score is higher than a
80           bad score.  Individual Learners will have their own procedures for
81           determining scores, so you cannot compare one Learner's score with
82           another Learner's - for instance, one Learner might always give
83           scores between 0 and 1, and another Learner might always return
84           scores less than 0.  You often cannot compare scores from a single
85           Learner on two different categorization tasks either.
86
87       all_categories()
88           Returns the list of category names specified with the
89           "all_categories" constructor parameter.
90
91       document_name()
92           Returns the value of the "document_name" parameter specified as a
93           constructor parameter, or "undef" if none was specified.
94

AUTHOR

96       Ken Williams <ken@mathforum.org>
97
99       This distribution is free software; you can redistribute it and/or
100       modify it under the same terms as Perl itself.  These terms apply to
101       every file in the distribution - if you have questions, please contact
102       the author.
103
104
105
106perl v5.36.0                      2023-01-19    AI::Categorizer::Hypothesis(3)
Impressum