AI::Ca...::Weka(3pm)
π AI::Ca...::Weka β bestie edition π
User Contributed Perl Documentation β¨ part of the AI::Categorizer friend group
πΈ NAME πΈ
AI::Categorizer::Learner::Weka β a pass-through wrapper to the Weka system π
Basically it's the middleman bestie. It doesn't do the learning itself, it just hands your data over to Weka and lets them cook. π
β¨ SYNOPSIS β¨
use AI::Categorizer::Learner::Weka;
# Here $k is an AI::Categorizer::KnowledgeSet object
my $nb = new AI::Categorizer::Learner::Weka(...parameters...);
$nb->train(knowledge_set => $k);
$nb->save_state('filename');
... time passes ...
$nb = AI::Categorizer::Learner->restore_state('filename');
my $c = new AI::Categorizer::Collection::Files( path => ... );
while (my $document = $c->next) {
my $hypothesis = $nb->categorize($document);
print "Best assigned category: ", $hypothesis->best_category, "\n";
}
okay so the flow is: make a learner, train it on your $k (your AI::Categorizer::KnowledgeSet, no cap), save it, ghost it for a while, restore it, then loop through documents and print the vibe β sorry, the best_category. π¦
π DESCRIPTION π
Real talk: this class doesn't implement any machine learners of its own. Not one. It literally just passes the data through to the Weka machine learning system (http://www.cs.waikato.ac.nz/~ml/weka/). π«Ά
And like, that's the point β it gives you access to a whole collection of machine learning algorithms that aren't otherwise implemented in AI::Categorizer. It's giving β¨expansion packβ¨ energy.
Currently this is a simple command-line wrapper that calls java subprocesses. In the future this may be converted to an Inline::Java wrapper for better performance (faster running times). π
BUT β and hear me out β if you're looking for really great performance, you're probably looking in the wrong place. π This Weka wrapper is intended more as a way to try lots of different machine learning methods. It's a sampler platter, not a michelin star restaurant, iykyk. π
π§ METHODS π§
This class inherits from the AI::Categorizer::Learner class, so all of its methods are available unless explicitly mentioned here. Inheritance said "I got you bestie." π
π new()
Creates a new Weka Learner and returns it. Iconic. π
In addition to the parameters accepted by the AI::Categorizer::Learner class, the Weka subclass accepts the following parameters:
java_pathβ Specifies where thejavaexecutable can be found on this system. The default is simplyjava, meaning that it will search yourPATHto find java. πjava_argsβ Specifies a list of any additional arguments to give to the java process. Commonly it's necessary to allocate more memory than the default, using an argument like-Xmx130MB. (she's hungry, feed her RAM π°)weka_pathβ Specifies the path to theweka.jarfile containing the Weka bytecode. If Weka has been installed somewhere in your javaCLASSPATH, you needn't specify aweka_path. NoCLASSPATH? Then yeah, you gotta tell her where the jar lives.weka_classifierβ Specifies the Weka class to use for a categorizer. The default isweka.classifiers.NaiveBayes. Consult your Weka documentation for a list of other classifiers available. πweka_argsβ Specifies a list of any additional arguments to pass to the Weka classifier class when building the categorizer. π οΈtmpdirβ A directory in which temporary files will be written when training the categorizer and categorizing new documents. The default is given byFile::Spec->tmpdir. ποΈ
π₯ train(knowledge_set => $k)
Trains the categorizer. This prepares it for later use in categorizing documents. Glow-up arc, basically. π
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. π
π¦ categorize($document)
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.
tl;dr β you give her a doc, she gives you her best guess wrapped in a whole Hypothesis object. Main character energy fr fr. π
π save_state($path)
Saves the categorizer for later use. This method is inherited from AI::Categorizer::Storable. πΎ
Yes bestie, she can be saved. Come back whenever. She'll be waiting. π«Ά
πΈ AUTHOR πΈ
Ken Williams, ken@mathforum.org
π 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. πͺ
β SEE ALSO β
And that's the whole page, bestie!! This was written for perl v5.42.0 and dated 2025-07-25 β so if you're reading this from the future, hi, ily, the vibes still hold. πβ¨π
π¦ 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