PHP-ML is a fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Preprocessing, Feature Extraction and much more in one library. The library support : Association rule learning, Classification, Regression, Clustering, Metric, Workflow, Neural Network, Cross validation, Preprocessing, Feature extraction, Models management and some Math functions. Datasets supported as Array, CSV and Files. Three predefined datasets are available to be used in the library which are Iris, Wine and Glass.

A simple example of classification:

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);

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

Currently the library is still under development, but You can install it with Composer:

composer require php-ai/php-ml

PHP-ML library requires PHP >= 7.0 and available under an MIT license. Example scripts are available in a separate repository php-ai/php-ml-examples. Documentation is available here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here