keinos/php7-ml

By keinos

Updated about 4 years ago

PHP Machine Learning Library (PHP-ML) on Alpine.

Image
0

139

Dockerfile of PHP7-ML

Dockerfile of PHP-ML, the Machine Learning library for PHP, on Alpine Linux.

docker pull keinos/php7-ml:latest

Basic Image Info

Sample Usage

Mount the script on /app and run.

$ docker run --rm -it -v $(pwd)/sample.php:/app/sample.php keinos/php7-ml:latest php /app/sample.php
  • Sample script:

    <?php
    /* sample.php */
    
    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]);
    // returns 'b'
    

Docker Pull Command

docker pull keinos/php7-ml