https://github.com/fieg/bayes
Implementation of Naive Bayes Classifier algorithm in PHP.
https://github.com/fieg/bayes
bayes machine-learning naive-bayes-classifier php
Last synced: 7 months ago
JSON representation
Implementation of Naive Bayes Classifier algorithm in PHP.
- Host: GitHub
- URL: https://github.com/fieg/bayes
- Owner: fieg
- Created: 2014-01-22T20:41:55.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-24T15:55:16.000Z (about 8 years ago)
- Last Synced: 2024-04-24T10:15:13.421Z (about 1 year ago)
- Topics: bayes, machine-learning, naive-bayes-classifier, php
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 71
- Watchers: 7
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Naive Bayes Classifier
======================Implementation of Naive Bayes Classifier algorithm in PHP.
Based on [Machine Learning: Naive Bayes Document Classification Algorithm in Javascript](http://burakkanber.com/blog/machine-learning-naive-bayes-1/) by Burak Kanber.
[](https://travis-ci.org/fieg/bayes)
Getting started
---------------```php
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)
}
```