datatransformer test set

This commit is contained in:
Arkadiusz Kondas 2016-05-06 22:38:50 +02:00
parent 4ac2ac8a35
commit dfb7b6b108
3 changed files with 31 additions and 0 deletions

View File

@ -23,6 +23,21 @@ class DataTransformer
return $set;
}
/**
* @param array $samples
*
* @return string
*/
public static function testSet(array $samples): string
{
$set = '';
foreach ($samples as $sample) {
$set .= sprintf('0 %s %s', self::sampleRow($sample), PHP_EOL);
}
return $set;
}
/**
* @param array $labels
*

View File

@ -83,5 +83,6 @@ class SupportVectorMachine
public function predict(array $samples)
{
$testSet = DataTransformer::testSet();
}
}

View File

@ -22,4 +22,19 @@ class DataTransformerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($trainingSet, DataTransformer::trainingSet($samples, $labels));
}
public function testTransformSamplesToTestSet()
{
$samples = [[1, 1], [2, 1], [3, 2], [4, 5]];
$testSet =
'0 1:1 2:1 '.PHP_EOL.
'0 1:2 2:1 '.PHP_EOL.
'0 1:3 2:2 '.PHP_EOL.
'0 1:4 2:5 '.PHP_EOL
;
$this->assertEquals($testSet, DataTransformer::testSet($samples));
}
}