【发布时间】:2019-07-07 18:18:54
【问题描述】:
我正在使用这个脚本https://php-ml.readthedocs.io/en/latest/ 来预测特定游戏的结果。
训练数据集如下所示:
team1, team2, H
team3, team4, A
team6, team12, D
team1, team4, ?
H、A、D 是结果(Home、Away、Drawn)
我尝试使用他们的示例,但如果我使用字符串而不是整数,则会出现错误(也许那个公式也不是正确的):
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]);
当我尝试使用字符串时,这是我得到的错误:
警告:第 29 行 C:\xampp12\htdocs\ml-football\vendor\php-ai\php-ml\src\Phpml\Math\Distance\Euclidean.php 中遇到的非数字值 PHP 警告:第 29 行 C:\xampp12\htdocs\ml-football\vendor\php-ai\php-ml\src\Phpml\Math\Distance\Euclidean.php 中遇到的非数字值
任何人都可以向我展示我正在寻找的结果的示例吗?
【问题讨论】:
标签: python php machine-learning php-ml