0

According to the example given here:

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

One dataset can have one 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? In effect teach the model that articles can have multiple labels or does this defeat the 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

Antony
  • 3,875
  • 30
  • 32
  • Can someone advise me why this has been minused? This is a genuine question. If I need to amend it I am happy to do so! – Antony May 05 '20 at 07:27

1 Answers1

0

Looking through the project code I see the use of one 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

Regards

Jon C.
  • 374
  • 1
  • 4
  • 14