mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2025-01-10 00:37:55 +00:00
datatransformer test set
This commit is contained in:
parent
4ac2ac8a35
commit
dfb7b6b108
@ -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
|
||||
*
|
||||
|
@ -83,5 +83,6 @@ class SupportVectorMachine
|
||||
|
||||
public function predict(array $samples)
|
||||
{
|
||||
$testSet = DataTransformer::testSet();
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user