php-cs-fixer

This commit is contained in:
Arkadiusz Kondas 2016-07-19 21:59:23 +02:00
parent 9665457159
commit 074dcf7470
2 changed files with 12 additions and 14 deletions

View File

@ -1,4 +1,5 @@
<?php
declare (strict_types = 1);
namespace Phpml\Metric;
@ -40,13 +41,13 @@ class ClassificationReport
foreach ($actualLabels as $index => $actual) {
$predicted = $predictedLabels[$index];
$this->support[$actual]++;
++$this->support[$actual];
if ($actual === $predicted) {
$truePositive[$actual]++;
++$truePositive[$actual];
} else {
$falsePositive[$predicted]++;
$falseNegative[$actual]++;
++$falsePositive[$predicted];
++$falseNegative[$actual];
}
}
@ -144,5 +145,4 @@ class ClassificationReport
return $labels;
}
}

View File

@ -1,4 +1,5 @@
<?php
declare (strict_types = 1);
namespace tests\Phpml\Metric;
@ -7,7 +8,6 @@ use Phpml\Metric\ClassificationReport;
class ClassificationReportTest extends \PHPUnit_Framework_TestCase
{
public function testClassificationReportGenerateWithStringLabels()
{
$labels = ['cat', 'ant', 'bird', 'bird', 'bird'];
@ -21,12 +21,10 @@ class ClassificationReportTest extends \PHPUnit_Framework_TestCase
$support = ['cat' => 1, 'ant' => 1, 'bird' => 3];
$average = ['precision' => 0.75, 'recall' => 0.83, 'f1score' => 0.73];
$this->assertEquals($precision, $report->getPrecision(), '', 0.01);
$this->assertEquals($recall, $report->getRecall(), '', 0.01);
$this->assertEquals($f1score, $report->getF1score(), '', 0.01);
$this->assertEquals($support, $report->getSupport(), '', 0.01);
$this->assertEquals($average, $report->getAverage(), '', 0.01);
}
}