fieg / bayes
Implementation of Naive Bayes Classifier algorithm in PHP.
Installs: 87 674
Dependents: 1
Suggesters: 0
Security: 0
Stars: 71
Watchers: 7
Forks: 16
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-29 04:19:55 UTC
README
Implementation of Naive Bayes Classifier algorithm in PHP.
Based on Machine Learning: Naive Bayes Document Classification Algorithm in Javascript by Burak Kanber.
Getting started
use Fieg\Bayes\Classifier; use Fieg\Bayes\Tokenizer\WhitespaceAndPunctuationTokenizer; $tokenizer = new WhitespaceAndPunctuationTokenizer(); $classifier = new Classifier($tokenizer); $classifier->train('en', 'This is english'); $classifier->train('fr', 'Je suis Hollandais'); $result = $classifier->classify('This is a naive bayes classifier');
Which would result in:
array(2) {
'en' =>
double(0.9)
'fr' =>
double(0.1)
}