PHPackages                             fieg/bayes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fieg/bayes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fieg/bayes
==========

Implementation of Naive Bayes Classifier algorithm in PHP.

1.0.3(9y ago)7394.1k↓50%15PHPPHP &gt;=5.4

Since Jan 22Pushed 8y ago6 watchersCompare

[ Source](https://github.com/fieg/bayes)[ Packagist](https://packagist.org/packages/fieg/bayes)[ Docs](https://github.com/fieg/bayes)[ RSS](/packages/fieg-bayes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (6)Used By (0)

Naive Bayes Classifier
======================

[](#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.

[![Build Status](https://camo.githubusercontent.com/3cfc0ae9cde1c2e1337dcab63cf228b5420e42eea09dcf53c22a762f7510dbd7/68747470733a2f2f7472617669732d63692e6f72672f666965672f62617965732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/fieg/bayes)

Getting started
---------------

[](#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)
}

```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~287 days

Total

4

Last Release

3637d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5eceacbc3912547ac51ba584798cc5a7c1bfae49b714978f62b6e1af389307dd?d=identicon)[fieg](/maintainers/fieg)

---

Top Contributors

[![fieg](https://avatars.githubusercontent.com/u/1086908?v=4)](https://github.com/fieg "fieg (16 commits)")[![benniekrijger](https://avatars.githubusercontent.com/u/6360518?v=4)](https://github.com/benniekrijger "benniekrijger (2 commits)")

---

Tags

bayesmachine-learningnaive-bayes-classifierphpbayesclassifierlearningmachinenaive

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fieg-bayes/health.svg)

```
[![Health](https://phpackages.com/badges/fieg-bayes/health.svg)](https://phpackages.com/packages/fieg-bayes)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[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

17237.0k1](/packages/camspiers-statistical-classifier)[niiknow/bayes

a machine learning lib

6950.0k](/packages/niiknow-bayes)[patrickschur/stanford-nlp-tagger

PHP wrapper for the Stanford Natural Language Processing library. Supports POSTagger and CRFClassifier.

7426.7k1](/packages/patrickschur-stanford-nlp-tagger)[sabatinomasala/replicate-php

PHP client for the Replicate API

3743.6k](/packages/sabatinomasala-replicate-php)[hybridlogic/classifier

A Naive Bayesian classification library for PHP with support for different tokenizers to optimize string classification.

801.4k](/packages/hybridlogic-classifier)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
