Наследование: implements Classifier, use trait Phpml\Helper\Trainable, use trait Phpml\Helper\Predictable
Пример #1
0
 public function testPredictArrayOfSamples()
 {
     $trainSamples = [[5, 1, 1], [1, 5, 1], [1, 1, 5]];
     $trainLabels = ['a', 'b', 'c'];
     $testSamples = [[3, 1, 1], [5, 1, 1], [4, 3, 8], [1, 1, 2], [2, 3, 2], [1, 2, 1], [9, 5, 1], [3, 1, 2]];
     $testLabels = ['a', 'a', 'c', 'c', 'b', 'b', 'a', 'a'];
     $classifier = new NaiveBayes();
     $classifier->train($trainSamples, $trainLabels);
     $predicted = $classifier->predict($testSamples);
     $this->assertEquals($testLabels, $predicted);
 }