2017 © Pedro Peláez
 

library statistical-classifier

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

image

camspiers/statistical-classifier

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  • Sunday, August 31, 2014
  • by camspiers
  • Repository
  • 21 Watchers
  • 163 Stars
  • 24,038 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 24 Forks
  • 5 Open issues
  • 23 Versions
  • 9 % Grown

The README.md

PHP Classifier

Build Status Latest Stable Version, (*1)

PHP Classifier uses semantic versioning, it is currently at major version 0, so the public API should not be considered stable., (*2)

What is it?

PHP Classifier is a text classification library with a focus on reuse, customizability and performance. Classifiers can be used for many purposes, but are particularly useful in detecting spam., (*3)

Features

  • Complement Naive Bayes Classifier
  • SVM (libsvm) Classifier
  • Highly customizable (easily modify or build your own classifier)
  • Command-line interface via separate library (phar archive)
  • Multiple data import types to get your data into the classifier (Directory of files, Database queries, Json, Serialized arrays)
  • Multiple types of model caching
  • Compatible with HipHop VM

Installation

$ composer require camspiers/statistical-classifier

SVM Support

For SVM Support both libsvm and php-svm are required. For installation intructions refer to php-svm., (*4)

Usage

Non-cached Naive Bayes

use Camspiers\StatisticalClassifier\Classifier\ComplementNaiveBayes;
use Camspiers\StatisticalClassifier\DataSource\DataArray;

$source = new DataArray();
$source->addDocument('spam', 'Some spam document');
$source->addDocument('spam', 'Another spam document');
$source->addDocument('ham', 'Some ham document');
$source->addDocument('ham', 'Another ham document');

$classifier = new ComplementNaiveBayes($source);
$classifier->is('ham', 'Some ham document'); // bool(true)
$classifier->classify('Some ham document'); // string "ham"

Non-cached SVM

use Camspiers\StatisticalClassifier\Classifier\SVM;
use Camspiers\StatisticalClassifier\DataSource\DataArray;

$source = new DataArray()
$source->addDocument('spam', 'Some spam document');
$source->addDocument('spam', 'Another spam document');
$source->addDocument('ham', 'Some ham document');
$source->addDocument('ham', 'Another ham document');

$classifier = new SVM($source);
$classifier->is('ham', 'Some ham document'); // bool(true)
$classifier->classify('Some ham document'); // string "ham"

Caching models

Caching models requires maximebf/CacheCache which can be installed via packagist. Additional caching systems can be easily integrated., (*5)

Cached Naive Bayes

use Camspiers\StatisticalClassifier\Classifier\ComplementNaiveBayes;
use Camspiers\StatisticalClassifier\Model\CachedModel;
use Camspiers\StatisticalClassifier\DataSource\DataArray;

$source = new DataArray();
$source->addDocument('spam', 'Some spam document');
$source->addDocument('spam', 'Another spam document');
$source->addDocument('ham', 'Some ham document');
$source->addDocument('ham', 'Another ham document');

$model = new CachedModel(
    'mycachename',
    new CacheCache\Cache(
        new CacheCache\Backends\File(
            array(
                'dir' => __DIR__
            )
        )
    )
);

$classifier = new ComplementNaiveBayes($source, $model);
$classifier->is('ham', 'Some ham document'); // bool(true)
$classifier->classify('Some ham document'); // string "ham"

Cached SVM

use Camspiers\StatisticalClassifier\Classifier\SVM;
use Camspiers\StatisticalClassifier\Model\SVMCachedModel;
use Camspiers\StatisticalClassifier\DataSource\DataArray;

$source = new DataArray();
$source->addDocument('spam', 'Some spam document');
$source->addDocument('spam', 'Another spam document');
$source->addDocument('ham', 'Some ham document');
$source->addDocument('ham', 'Another ham document');

$model = new Model\SVMCachedModel(
    __DIR__ . '/model.svm',
    new CacheCache\Cache(
        new CacheCache\Backends\File(
            array(
                'dir' => __DIR__
            )
        )
    )
);

$classifier = new SVM($source, $model);
$classifier->is('ham', 'Some ham document'); // bool(true)
$classifier->classify('Some ham document'); // string "ham"

Unit testing

statistical-classifier/ $ composer install --dev
statistical-classifier/ $ phpunit

The Versions

31/08 2014

dev-master

9999999-dev http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

05/01 2014

0.8.0

0.8.0.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

05/01 2014

dev-stemmer-exception

dev-stemmer-exception http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

16/12 2013

0.7.2

0.7.2.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

16/12 2013

0.7.1

0.7.1.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

02/12 2013

0.7.0

0.7.0.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

classifier bayes naive svm

15/09 2013

0.6.3

0.6.3.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

15/09 2013

0.6.2

0.6.2.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

12/09 2013

0.6.1

0.6.1.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

12/09 2013

0.6.0

0.6.0.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

08/09 2013

0.5.5

0.5.5.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

22/04 2013

0.5.4

0.5.4.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

14/04 2013

0.5.3

0.5.3.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

13/04 2013

0.5.2

0.5.2.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

07/04 2013

0.5.0

0.5.0.0 http://php-classifier.com/

A PHP implementation of Complement Naive Bayes and SVM statistical classifiers, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive svm statistical porter

01/04 2013

0.4.3

0.4.3.0 http://php-classifier.com/

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive statistical porter

01/04 2013

0.4.2

0.4.2.0 http://php-classifier.com/

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive statistical porter

01/04 2013

0.4.1

0.4.1.0 http://php-classifier.com/

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive statistical porter

01/04 2013

0.4.0

0.4.0.0 http://php-classifier.com/

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer stemmer classifier bayes normalizer naive statistical porter

19/03 2013

0.3.0

0.3.0.0 https://github.com/camspiers/statistical-classifier

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer classifier bayes normalizer naive statistical porter stemer

17/03 2013

0.2.1

0.2.1.0 https://github.com/camspiers/statistical-classifier

A PHP implementation of a Naive Bayes statistical classifier, including a structure for building other classifier, multiple data sources and multiple caching backends

  Sources   Download

MIT

The Requires

 

The Development Requires

cache command-line tokenizer classifier bayes normalizer naive statistical porter stemer