简体   繁体   English

PHP ML 可以有多个 label 值吗?

[英]Can PHP ML have multiple label values?

According to the example given here:根据此处给出的示例:

https://php-ml.readthedocs.io/en/latest/machine-learning/datasets/array-dataset/ https://php-ml.readthedocs.io/en/latest/machine-learning/datasets/array-dataset/

One dataset can have one label.一个数据集可以有一个 label。 I am brand new to ML and am trying to classify articles that have multiple categories per article so is it possible to do something like the following?我是 ML 的新手,我正在尝试对每篇文章有多个类别的文章进行分类,所以是否可以执行以下操作? In effect teach the model that articles can have multiple labels or does this defeat the object.实际上,教导 model 文章可以有多个标签,否则这会打败 object。

use Phpml\Dataset\ArrayDataset;

$dataset = new ArrayDataset([[1, 1], [2, 1], [3, 2], [4, 1]], [['a','b'],['a','c'],['b','d'],['b','e']]);

It would appear I'm not the only one who is experiencing this - https://github.com/php-ai/php-ml/issues/423看来我不是唯一遇到这种情况的人-https://github.com/php-ai/php-ml/issues/423

Looking through the project code I see the use of one label.翻阅项目代码,我看到一个 label 的使用。

$this->labels = array_map('strval', array_flip(array_flip($this->targets)));
    foreach ($this->labels as $label) {
        $samples = $this->getSamplesByLabel($label);
        $this->p[$label] = count($samples) / $this->sampleCount;
        $this->calculateStatistics($label, $samples);

There were other functions, though I did not see any that would take and array instead of a string.还有其他函数,尽管我没有看到任何可以使用数组而不是字符串的函数。

Github: https://github.com/php-ai/php-ml Github: https://github.com/php-ai/php-ml

Regards问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM