PHP code example of fieg / bayes
1. Go to this page and download the library: Download fieg/bayes library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fieg / bayes example snippets
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');
array(2) {
'en' =>
double(0.9)
'fr' =>
double(0.1)
}