I am using this script https://php-ml.readthedocs.io/en/latest/ to predict the result of a particular game.
The training dataset looks like this:
team1, team2, H
team3, team4, A
team6, team12, D
team1, team4, ?
H, A, D being the results (Home, Away, Drawn)
I tried using their example, but I get an error if I use strings instead of integers (and maybe that one is no the right formula also):
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);
$classifier->predict([3, 2]);
When I try with strings this is the error that I get:
Warning: A non-numeric value encountered in C:\xampp12\htdocs\ml-football\vendor\php-ai\php-ml\src\Phpml\Math\Distance\Euclidean.php on line 29 PHP Warning: A non-numeric value encountered in C:\xampp12\htdocs\ml-football\vendor\php-ai\php-ml\src\Phpml\Math\Distance\Euclidean.php on line 29
Anyone can show me an example of the results that I am looking for?