assertEquals(0.5, Accuracy::score($actualLabels, $predictedLabels)); } public function testCalculateNotNormalizedScore() { $actualLabels = ['a', 'b', 'a', 'b']; $predictedLabels = ['a', 'b', 'b', 'b']; $this->assertEquals(3, Accuracy::score($actualLabels, $predictedLabels, false)); } public function testAccuracyOnDemoDataset() { $dataset = new RandomSplit(new IrisDataset(), 0.5, 123); $classifier = new SVC(Kernel::RBF); $classifier->train($dataset->getTrainSamples(), $dataset->getTrainLabels()); $predicted = $classifier->predict($dataset->getTestSamples()); $accuracy = Accuracy::score($dataset->getTestLabels(), $predicted); $this->assertEquals(0.959, $accuracy, '', 0.01); } }