PHP-Machine Learning on Alpine + PHP8-ish + JIT enabled.
979
Dockerfile of PHP-ML, the Machine Learning library for PHP. (PHP8-ish + JIT on Alpine Linux)
docker pull keinos/php8-ml:latest
For ARMv6l(arm32v6) architecture such as RaspberryPi Zero W use the below image.
docker pull keinos/php8-ml:arm32v6
www-data/usr/local/bin/composer/app (alias of /home/www-data)composer require php-ai/php-ml)
Mount the script on /app and run.
$ docker run --rm -it -v $(pwd)/sample.php:/app/sample.php keinos/php8-ml:latest /bin/sh
/ $ cd /app
/ $ ls
sample.php
/ $ composer require php-ai/php-ml
...
/ $ php ./sample.php
b
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]), PHP_EOL;
// expect return: 'b'
Clone this repo.
Decide tag name to use as a base image from:
arm32v6 arm(ARMv7) amd latest(default, x86_64)Build image specifing the base image tag.
The below sample will build with the base image keinos/php8-jit:arm32v6 as myname/php8-ml:local.
docker build --build-arg NAME_TAG_IMAGE=arm32v6 -t myname/php8-ml:local .
Content type
Image
Digest
Size
47.6 MB
Last updated
almost 7 years ago
docker pull keinos/php8-ml