Git Product home page Git Product logo

ai-classifier's Introduction

SYNOPSIS

my $cl = AI::Classifier::Text->new(
  training_data => [
       {  
           attributes => _hash(qw(sheep very valuable farming)),
           labels => ['farming']
       },
       {  
           attributes => _hash(qw(farming requires many kinds animals)),
           labels => ['farming']
       },
       {  
           attributes => _hash(qw(vampires drink blood vampires may staked)),
           labels => ['vampire']
       },
);
# the above creates a default AI::NaiveBayes classifier and feeds it the training data

my $res = $cl->classify("I would like to begin farming sheep" );

$res    = $cl->classify("I would like to begin farming sheep", { new_user => 1 });

print $res->best_category; 
$cl->store('some-file');
# later
my $cl = AI::Classifier::Text->load('some-file');
my $res = $cl->classify("do cats eat sheep?");

DESCRIPTION

AI::Classifier::Text combines a lexical analyzer (by default being AI::Classifier::Text::Analyzer) and a compatible classifier to perform text classification.

The constructor requires either a compatible trained classifier (like AI::NaiveBayes) - or training_data parameter with a list of training examples. In that later case it creates the default AI::NaiveBayes classifier and traubs it before constructing the AI::Classifier::Text object.

If your training data does not feet into the computer memory, or you want a different classifier to use - than train the classifier first and then pass it to the AI::Classifier::Text constructor.

This is partially based on AI::TextCategorizer.

ATTRIBUTES

classifier

An object that'll perform classification of supplied feature vectors. Has to define a classify() method, which accepts a hash refence. The return value of AI::Classifier::Text->classify() will be the return value of classifier's classify() method.

This attribute has to be supplied to the new() method during object creation.

analyzer

The class performing lexical analysis of the text in order to produce a feature vector. This defaults to AI::Classifier::Text::Analyzer.

METHODS

new(classifier => $foo)

Creates a new AI::Classifier::Text object. It requires either the classifier or the training data passed to it.

classify($document, $features)

Categorize the given document. A lexical analyzer will be used to extract features from $document, and in addition to that the features from $features hash reference will be added. The return value comes directly from the classifier object's classify method.

SEE ALSO

AI::NaiveBayes (3), AI::Categorizer(3)

ai-classifier's People

Contributors

zby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.