AI::Categorizer::Learner::DecisionTree - Decision Tree Learner
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";
}
This class implements a Decision Tree machine learner, using
"AI::DecisionTree" to do the internal work.
This class inherits from the
"AI::Categorizer::Learner" class, so all of
its methods are available unless explicitly mentioned here.
Creates a new DecisionTree Learner and returns it.
Trains the categorizer. This prepares it for later use in categorizing
documents. The "knowledge_set" parameter
must provide an object of the class
"AI::Categorizer::KnowledgeSet" (or a
subclass thereof), populated with lots of documents and categories. See
AI::Categorizer::KnowledgeSet for the details of how to create such an object.
Returns an "AI::Categorizer::Hypothesis"
object representing the categorizer's "best guess" about which
categories the given document should be assigned to. See
AI::Categorizer::Hypothesis for more details on how to use this object.
Saves the categorizer for later use. This method is inherited from
"AI::Categorizer::Storable".
Ken Williams, ken@mathforum.org
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.