PHPackages                             ovg288/php-ml - 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. ovg288/php-ml

ActiveLibrary

ovg288/php-ml
=============

PHP-ML - Machine Learning library for PHP

011.6kPHPCI failing

Since May 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ovg288/php-ml)[ Packagist](https://packagist.org/packages/ovg288/php-ml)[ RSS](/packages/ovg288-php-ml/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-ML - Machine Learning library for PHP
=========================================

[](#php-ml---machine-learning-library-for-php)

[![Minimum PHP Version](https://camo.githubusercontent.com/824c5c4ccb56537db3b3b53bb43d7b8edc6286f3b3d1705525e0821dfd22d27e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e312d3838393242462e737667)](https://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/e22dd29f73bf361e53b3f6e7a04fe6a6d9d63eb6e1aace085e042bf0af6c4a90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d61692f7068702d6d6c2e737667)](https://packagist.org/packages/php-ai/php-ml)[![Build Status](https://camo.githubusercontent.com/15359cfeec5a6d5d07c4af42e008c2276be5f52b3c227d7e55ad1f81608ad621/68747470733a2f2f7472617669732d63692e6f72672f7068702d61692f7068702d6d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-ai/php-ml)[![Documentation Status](https://camo.githubusercontent.com/f5dba9d7890a5374a8e29ef9d6b9c20ea697f3ae1e7fd30be43a5e0b678d4aa1/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f7068702d6d6c2f62616467652f3f76657273696f6e3d6d6173746572)](http://php-ml.readthedocs.org/)[![Total Downloads](https://camo.githubusercontent.com/5520b32bf7f297eff12f576b02e8f42b90fb18475c758e400cd473af81c9746a/68747470733a2f2f706f7365722e707567782e6f72672f7068702d61692f7068702d6d6c2f646f776e6c6f6164732e737667)](https://packagist.org/packages/php-ai/php-ml)[![License](https://camo.githubusercontent.com/976b950a432a2a11bad43aaab3afc222b6d27eaf53f8ab507f1c104c6e47c0d6/68747470733a2f2f706f7365722e707567782e6f72672f7068702d61692f7068702d6d6c2f6c6963656e73652e737667)](https://packagist.org/packages/php-ai/php-ml)[![Coverage Status](https://camo.githubusercontent.com/7f187e366b592631eb45cc716fece4216b3b84158a9cd76c390ff5b0be563775/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d61692f7068702d6d6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/php-ai/php-ml?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8424e75e0589ec2b0f68a2dcdaa098b40bb9a4d4dc2f471cd54543d833a1b546/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068702d61692f7068702d6d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/php-ai/php-ml/?branch=master)

 [![](https://github.com/php-ai/php-ml/raw/master/docs/assets/php-ml-logo.png)](https://github.com/php-ai/php-ml/raw/master/docs/assets/php-ml-logo.png)

Fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Neural Network, Preprocessing, Feature Extraction and much more in one library.

PHP-ML requires PHP &gt;= 7.1.

Simple example of classification:

```
require_once __DIR__ . '/vendor/autoload.php';

use Phpml\Classification\KNearestNeighbors;

$samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
$labels = ['a', 'a', 'a', 'b', 'b', 'b'];

$classifier = new KNearestNeighbors();
$classifier->train($samples, $labels);

echo $classifier->predict([3, 2]);
// return 'b'
```

Awards
------

[](#awards)

[ ![](https://camo.githubusercontent.com/14bf7a93b88b218bad3fe7203139bc06df9f4a64b12cca157aade2596a37867e/687474703a2f2f7777772e7965676f723235362e636f6d2f696d616765732f61776172642f323031372f77696e6e65722d69746372616674736d616e706c2e706e67)](http://www.yegor256.com/2016/10/23/award-2017.html)Documentation
-------------

[](#documentation)

To find out how to use PHP-ML follow [Documentation](http://php-ml.readthedocs.org/).

Installation
------------

[](#installation)

Currently this library is in the process of being developed, but You can install it with Composer:

```
composer require php-ai/php-ml

```

Examples
--------

[](#examples)

Example scripts are available in a separate repository [php-ai/php-ml-examples](https://github.com/php-ai/php-ml-examples).

Datasets
--------

[](#datasets)

Public datasets are available in a separate repository [php-ai/php-ml-datasets](https://github.com/php-ai/php-ml-datasets).

Features
--------

[](#features)

- Association rule learning
    - [Apriori](http://php-ml.readthedocs.io/en/latest/machine-learning/association/apriori/)
- Classification
    - [SVC](http://php-ml.readthedocs.io/en/latest/machine-learning/classification/svc/)
    - [k-Nearest Neighbors](http://php-ml.readthedocs.io/en/latest/machine-learning/classification/k-nearest-neighbors/)
    - [Naive Bayes](http://php-ml.readthedocs.io/en/latest/machine-learning/classification/naive-bayes/)
    - Decision Tree (CART)
    - Ensemble Algorithms
        - Bagging (Bootstrap Aggregating)
        - Random Forest
        - AdaBoost
    - Linear
        - Adaline
        - Decision Stump
        - Perceptron
        - LogisticRegression
- Regression
    - [Least Squares](http://php-ml.readthedocs.io/en/latest/machine-learning/regression/least-squares/)
    - [SVR](http://php-ml.readthedocs.io/en/latest/machine-learning/regression/svr/)
- Clustering
    - [k-Means](http://php-ml.readthedocs.io/en/latest/machine-learning/clustering/k-means/)
    - [DBSCAN](http://php-ml.readthedocs.io/en/latest/machine-learning/clustering/dbscan/)
    - Fuzzy C-Means
- Metric
    - [Accuracy](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/accuracy/)
    - [Confusion Matrix](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/confusion-matrix/)
    - [Classification Report](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/classification-report/)
- Workflow
    - [Pipeline](http://php-ml.readthedocs.io/en/latest/machine-learning/workflow/pipeline)
- Neural Network
    - [Multilayer Perceptron Classifier](http://php-ml.readthedocs.io/en/latest/machine-learning/neural-network/multilayer-perceptron-classifier/)
- Cross Validation
    - [Random Split](http://php-ml.readthedocs.io/en/latest/machine-learning/cross-validation/random-split/)
    - [Stratified Random Split](http://php-ml.readthedocs.io/en/latest/machine-learning/cross-validation/stratified-random-split/)
- Feature Selection
    - [Variance Threshold](http://php-ml.readthedocs.io/en/latest/machine-learning/feature-selection/variance-threshold/)
    - [SelectKBest](http://php-ml.readthedocs.io/en/latest/machine-learning/feature-selection/selectkbest/)
- Preprocessing
    - [Normalization](http://php-ml.readthedocs.io/en/latest/machine-learning/preprocessing/normalization/)
    - [Imputation missing values](http://php-ml.readthedocs.io/en/latest/machine-learning/preprocessing/imputation-missing-values/)
- Feature Extraction
    - [Token Count Vectorizer](http://php-ml.readthedocs.io/en/latest/machine-learning/feature-extraction/token-count-vectorizer/)
        - NGramTokenizer
        - WhitespaceTokenizer
        - WordTokenizer
    - [Tf-idf Transformer](http://php-ml.readthedocs.io/en/latest/machine-learning/feature-extraction/tf-idf-transformer/)
- Dimensionality Reduction
    - PCA (Principal Component Analysis)
    - Kernel PCA
    - LDA (Linear Discriminant Analysis)
- Datasets
    - [Array](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/array-dataset/)
    - [CSV](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/csv-dataset/)
    - [Files](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/files-dataset/)
    - [SVM](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/svm-dataset/)
    - [MNIST](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/mnist-dataset.md)
    - Ready to use:
        - [Iris](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/demo/iris/)
        - [Wine](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/demo/wine/)
        - [Glass](http://php-ml.readthedocs.io/en/latest/machine-learning/datasets/demo/glass/)
- Models management
    - [Persistency](http://php-ml.readthedocs.io/en/latest/machine-learning/model-manager/persistency/)
- Math
    - [Distance](http://php-ml.readthedocs.io/en/latest/math/distance/)
    - [Matrix](http://php-ml.readthedocs.io/en/latest/math/matrix/)
    - [Set](http://php-ml.readthedocs.io/en/latest/math/set/)
    - [Statistic](http://php-ml.readthedocs.io/en/latest/math/statistic/)
    - Linear Algebra

Contribute
----------

[](#contribute)

- [Guide: CONTRIBUTING.md](https://github.com/php-ai/php-ml/blob/master/CONTRIBUTING.md)
- [Issue Tracker: github.com/php-ai/php-ml](https://github.com/php-ai/php-ml/issues)
- [Source Code: github.com/php-ai/php-ml](https://github.com/php-ai/php-ml)

You can find more about contributing in [CONTRIBUTING.md](CONTRIBUTING.md).

License
-------

[](#license)

PHP-ML is released under the MIT Licence. See the bundled LICENSE file for details.

Author
------

[](#author)

Arkadiusz Kondas (@ArkadiuszKondas)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/006988a23f9eaaaccfaaa144f44788a0fb44d4173ec6411a198955f1c9506b2c?d=identicon)[ovg288](/maintainers/ovg288)

---

Top Contributors

[![ovg288](https://avatars.githubusercontent.com/u/46349309?v=4)](https://github.com/ovg288 "ovg288 (2 commits)")

### Embed Badge

![Health badge](/badges/ovg288-php-ml/health.svg)

```
[![Health](https://phpackages.com/badges/ovg288-php-ml/health.svg)](https://phpackages.com/packages/ovg288-php-ml)
```

PHPackages © 2026

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