AI::Ca...er::SVM(3pm)

๐Ÿ“ฆ
version 0.09 ยท 2 versions
, in fedora 43

๐Ÿ’– AI::Categorizer::Learner::SVM โœจ

okay bestie, welcome to the AI::Categorizer::Learner::SVM page, straight out of your friendly neighborhood User Contributed Perl Documentation ๐Ÿซถ this is the Support Vector Machine Learner and she is that girl ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

AI::Categorizer::Learner::SVM โ€” the Support Vector Machine Learner ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

no thoughts, just vibes and a little code, bestie:

  use AI::Categorizer::Learner::SVM;

  # Here $k is an AI::Categorizer::KnowledgeSet object

  my $l = new AI::Categorizer::Learner::SVM(...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";
  }

see how ... time passes ... ? that's the main character arc, honestly ๐Ÿ˜ญ save your state, come back later, restore it, keep categorizing. no notes. ๐Ÿ’ฏ


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

so this class is a Support Vector Machine machine learner โ€” and yes, that's a mouthful, it's giving "machine learner machine learner", we said what we said ๐Ÿ’€ โ€” and it's built on top of Cory Spencer's Algorithm::SVM module. ๐ŸŒŸ

and ngl, the tea is: in lots of the recent academic literature, SVMs perform very well for text categorization. lowkey iconic behavior from a math thing. ๐Ÿ“šโœจ


๐Ÿ’… METHODS ๐Ÿ’…

this class inherits from the AI::Categorizer::Learner class, so all of its methods are available too, unless we explicitly mention otherwise right here. periodt. ๐Ÿ‘‘

๐ŸŒˆ new()

Creates a new SVM Learner and hands it back to you, wrapped in a little bow ๐ŸŽ€

On top of the parameters that the AI::Categorizer::Learner class already accepts, the SVM subclass is also down to accept these:

  • svm_kernel โ€” tells it what type of kernel should be used when building the SVM. the default is 'linear'. the possible values are 'linear', 'polynomial', 'radial' and 'sigmoid'. pick your fighter, bestie ๐ŸฅŠ

๐ŸŒŸ train(knowledge_set => $k)

Trains the categorizer. this is the glow-up prep arc โ€” it gets everything ready so it can categorize documents later. ๐Ÿ’ช

the knowledge_set parameter must provide an object of the class AI::Categorizer::KnowledgeSet (or a subclass of it), and that object needs to be populated with lots and lots of documents and categories. like, feed her, she's hungry ๐Ÿ“

for the deets on how to actually create such an object, go peek at AI::Categorizer::KnowledgeSet.

๐Ÿฆ‹ categorize($document)

Returns an AI::Categorizer::Hypothesis object representing the categorizer's "best guess" about which categories the given document should be assigned to. ๐Ÿ”ฎ

wanna know how to use that object? AI::Categorizer::Hypothesis has all the details. go read it, i'll wait ๐Ÿ’œ

๐Ÿ‘‘ save_state($path)

Saves the categorizer so you can use it later. this one is inherited from AI::Categorizer::Storable. ๐Ÿ’พ

not me romanticizing a serialization method but the way she preserves your whole trained self for later? that's commitment fr fr ๐Ÿ˜ญ๐Ÿซถ

๐ŸŒธ AUTHOR ๐ŸŒธ

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. ๐Ÿช๐Ÿ’–


โญ SEE ALSO โญ

go follow them, they're mutuals ๐Ÿซถ


and that's the whole page, bestie!! ๐ŸŒˆ this was perl v5.42.0, dated 2025-07-25, and it lives in the User Contributed Perl Documentation section. slay, ate, no crumbs left. ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from