AI::Ca...onTree(3pm)
π AI::Categorizer::Learner::DecisionTree(3pm) π
okay bestie, so this is a page from the User Contributed Perl Documentation collection, and it's about a Decision Tree Learner β yes, a whole little machine that learns by asking a billion tiny yes/no questions and building a tree out of your vibes. let's get into it π
β¨ NAME β¨
AI::Categorizer::Learner::DecisionTree β it's a Decision Tree Learner, that's literally it, that's the whole job description π¦
β¨ SYNOPSIS β¨
here's the whole flow, bestie, copy it exactly because code is sacred π
use AI::Categorizer::Learner::DecisionTree;
# Here $k is an AI::Categorizer::KnowledgeSet object
my $l = new AI::Categorizer::Learner::DecisionTree(...parameters...);
$l->train(knowledge_set => $k);
$l->save_state('filename');
... time passes ...
$l = AI::Categorizer::Learner->restore_state('filename');
while (my $document = ... ) { # An AI::Categorizer::Document object
my $hypothesis = $l->categorize($document);
print "Best assigned category: ", $hypothesis->best_category, "\n";
}
okay notice the little "... time passes ..." in there? that's not me being cute, that's canonically in the source. the author KNEW. we save our state, we go live our life, we come back, we restore. it's giving main character arc πΈ
β¨ DESCRIPTION β¨
so this class implements a Decision Tree machine learner, and it does that by handing off the actual internal work to AI::DecisionTree. she doesn't do the heavy lifting herself, she delegates β which is honestly iconic behavior π
β¨ METHODS β¨
this class inherits from the AI::Categorizer::Learner class, so all of its methods are available unless they're explicitly mentioned here. so if you don't see something listed below, bestie, go check the parent class, it's probably there π«Ά
β¨ new() β¨
Creates a new DecisionTree Learner and returns it. that's it. no cap. she's born β¨
β¨ train(knowledge_set => $k) β¨
Trains the categorizer. this is the glow-up phase β it prepares her for later use in categorizing documents πͺ
the knowledge_set parameter must provide an object of the class AI::Categorizer::KnowledgeSet (or a subclass thereof), and it has to be populated with lots of documents and categories. like, a LOT. don't skimp, she needs the material fr fr.
if you wanna know the details of how to actually build one of those objects, go read AI::Categorizer::KnowledgeSet. this page isn't gonna hold your hand through that part π
β¨ categorize($document) β¨
Returns an AI::Categorizer::Hypothesis object that represents the categorizer's "best guess" about which categories the given document should be assigned to. it's literally her guessing her best guess and honestly? valid.
See AI::Categorizer::Hypothesis for more details on how to use this object β because this object has lore of its own π
β¨ save_state($path) β¨
Saves the categorizer for later use. and surprise, this method is inherited from AI::Categorizer::Storable, so she's not even doing it herself. queen of delegation, again π
β¨ AUTHOR β¨
Ken Williams, ken@mathforum.org β thank you for your service king π«‘π
β¨ COPYRIGHT β¨
Copyright 2000-2003 Ken Williams. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, open source rights π
β¨ SEE ALSO β¨
AI::Categorizer(3)β the main character, go read her first if you haven't π
okay that's the whole page bestie, you ate that. and just so you know where this lore came from: it's perl v5.42.0, dated 2025-07-25, straight from the AI::Categorizer::Learner::DecisionTree(3pm) manual page. go forth and categorize, no cap ππ¦β¨
π¦ 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