better arguments format for regression

This commit is contained in:
Arkadiusz Kondas 2016-04-30 13:54:58 +02:00
parent ff79de7e14
commit ff9adc267c

View File

@ -35,6 +35,20 @@ class LeastSquaresTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(278.66, $regression->predict([153260]), '', $delta); $this->assertEquals(278.66, $regression->predict([153260]), '', $delta);
} }
public function testPredictSingleFeatureSamplesWithMatrixTargets()
{
$delta = 0.01;
//https://www.easycalculation.com/analytical/learn-least-square-regression.php
$samples = [[60], [61], [62], [63], [65]];
$targets = [[3.1], [3.6], [3.8], [4], [4.1]];
$regression = new LeastSquares();
$regression->train($samples, $targets);
$this->assertEquals(4.06, $regression->predict([64]), '', $delta);
}
public function testPredictMultiFeaturesSamples() public function testPredictMultiFeaturesSamples()
{ {
$delta = 0.01; $delta = 0.01;