2017 © Pedro Peláez
 

library documer

Bayes algorithm implementation in PHP for auto document classification.

image

kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  • Monday, March 19, 2018
  • by stakisko
  • Repository
  • 8 Watchers
  • 77 Stars
  • 116 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 6 Versions
  • 43 % Grown

The README.md

Documer

Bayes algorithm implementation in PHP for auto document classification., (*1)

Concept

every document has key words e.g. Margaret Thatcher, (*2)

every document has a label e.g. Politics, (*3)

Suppose, that in every document there are key words all starting with an uppercase letter. We store these words in our DB end every time we need to guess a document against a particular label, we use Bayes algorithm., (*4)

Let's clear that out:, (*5)

Training:, (*6)

First, we tokenize the document and keep only our key words (All words starting with an uppercase letter) in an array. We store that array in our DB., (*7)

Guessing:, (*8)

This is very simple. Again, we parse the document we want to be classified and create an array with the key words. Here is the pseudo code:, (*9)

for every label in DB
    for every key word in document
        P(label/word) = P(word/label)P(label) / ( P(word/label)P(label) + (1 - P(word/label))(1 - P(label)) )

Usage

Install through composer, (*10)

"require": {
    "kbariotis/documer": "dev-master"
  },

Instantiate, (*11)

Pass a Storage Adapter object to the Documer Constructor., (*12)


$documer = new Documer\Documer(new \Documer\Storage\Memory());

Train, (*13)

$documer->train('politics', 'This is text about Politics and more');
$documer->train('philosophy', 'Socrates is an ancent Greek philosopher');
$documer->train('athletic', 'Have no idea about athletics. Sorry.');
$documer->train('athletic', 'Not a clue.');
$documer->train('athletic', 'It is just not my thing.');

Guess, (*14)

$scores = $documer->guess('What do we know about Socrates?');

$scores will hold an array with all labels of your system and the posibbility which the document will belong to each label., (*15)

Storage Adapters Implement Documer\Storage\Adapter to create your own Storage Adapter., (*16)

The Versions

19/03 2018

dev-master

9999999-dev http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

The Development Requires

machine learning classification bayes

23/12 2014

0.2.3

0.2.3.0 http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

The Development Requires

machine learning classification bayes

21/12 2014

0.2.2

0.2.2.0 http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

machine learning classification bayes

21/12 2014

0.2.1

0.2.1.0 http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

machine learning classification bayes

19/12 2014

0.2.0

0.2.0.0 http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

machine learning classification bayes

18/12 2014

0.1.0

0.1.0.0 http://github.com/kbariotis/documer

Bayes algorithm implementation in PHP for auto document classification.

  Sources   Download

MIT

The Requires

 

machine learning classification bayes