AI::Ca...othesis(3pm)
π AI::Categorizer::Hypothesis π
okay bestie, so you know how the manual calls this thing AI::Categorizer::Hypothesis? yeah. that's her. she embodies a set of category assignments. main character energy fr fr. β¨
π SYNOPSIS π
use AI::Categorizer::Hypothesis;
# Hypotheses are usually created by the Learner's categorize() method.
# (assume here that $learner and $document have been created elsewhere)
my $h = $learner->categorize($document);
print "Assigned categories: ", join ', ', $h->categories, "\n";
print "Best category: ", $h->best_category, "\n";
print "Assigned scores: ", join ', ', $h->scores( $h->categories ), "\n";
print "Chosen from: ", join ', ', $h->all_categories, "\n";
print +($h->in_category('geometry') ? '' : 'not '), "assigned to geometry\n";
π DESCRIPTION π
so. a Hypothesis is literally just a whole set of category assignments that some categorizer decided about one single document. that's it, that's the girl. π«Ά
and here's the thing β you might be nosy about different stuff at different times. like, what categories got assigned? or which one had the highest score? or was this one specific category in there or not? the way we have so many questions π. so this class exists to make all of those lil scenarios easy. iconic behaviour honestly.
π¦ METHODS π¦
β¨ new(%parameters)
returns a brand new Hypothesis object, fresh out the box. π
ngl though β if you're just a regular user of AI::Categorize, you do not usually make a Hypothesis yourself. they get handed to you by the Learner's categorize() method. that's the vibe. but like, if you really wanna build one by hand (maybe you're feeding it some fake data for testing, no judgement, we love a controlled experiment π§) then yeah, go off, use new().
here's what you can pass in when you're making a new Hypothesis:
all_categoriesβ a required parameter, bestie, don't skip it. this is the full set of every category that could possibly get assigned. you give it as a reference to an array of category names (as strings). the whole squad. πscoresβ a hash reference mapping each category to its assignment score. any score higher than the"threshold"is gonna count as assigned. periodt.thresholdβ a number that decides which categories actually get assigned. any category whose score is greater than or equal to"threshold"β assigned. any category whose score is lower than"threshold"β not assigned. that's the line, don't cross it. βdocument_nameβ optional string, the name of the document this hypothesis is about. just so she knows who she's talking about.
β¨ categories()
returns an ordered list of the categories the document got placed in, with the best matches first. π₯ categories come back by their string names.
β¨ best_category()
returns the name of the category with the highest score in this hypothesis. π
β οΈ okay important: that category might not actually be assigned if none of the categories' scores got above the threshold. so like, best β chosen. don't get it twisted. π
β¨ in_category($name)
returns true or false depending on whether the document landed in the given category. simple as that, slay.
β¨ scores(@names)
returns a list of result scores for the categories you asked about.
okay so real talk: the interface is still changing, and different Learners implement scoring in totally different ways, so officially? not much can be said about the scores. the one thing we know for sure is that a good score is higher than a bad score. that's the entire rulebook. π
individual Learners have their own procedures for figuring out scores, which means you cannot compare one Learner's score with another Learner's. like, one Learner might always give scores between 0 and 1, and another Learner might always return scores less than 0. completely different currencies bestie. πΈ
and honestly? you often can't even compare scores from a single Learner across two different categorization tasks either. so yeah. compare responsibly (or like, don't). π
β¨ all_categories()
returns the list of category names you specified with the "all_categories" constructor parameter. the whole roster. πΈ
β¨ document_name()
returns the value of the "document_name" parameter you passed to the constructor β or undef if you never specified one. ghosted by your own document name, it happens. π
π AUTHOR π
Ken Williams <ken@mathforum.org>
π COPYRIGHT π
this distribution is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π«Ά these terms apply to every single file in the distribution β if you've got questions, please contact the author.
and that's the whole page, bestie!! this was AI::Categorizer::Hypothesis, documented for perl v5.42.0, dated 2025-07-25 β go forth and categorize, you absolute icon πβ¨ππ¦
π¦ where this page comes from
- fedora 43: perl-AI-Categorizer 0.09-38.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms