fix index for trainging set

This commit is contained in:
Arkadiusz Kondas 2016-05-06 22:33:04 +02:00
parent 95caef8692
commit 4ac2ac8a35
4 changed files with 12 additions and 8 deletions

View File

@ -51,7 +51,7 @@ class DataTransformer
{
$row = [];
foreach ($sample as $index => $feature) {
$row[] = sprintf('%s:%s', $index, $feature);
$row[] = sprintf('%s:%s', $index + 1, $feature);
}
return implode(' ', $row);

View File

@ -27,7 +27,7 @@ class SupportVectorMachine
private $binPath;
/**
* @var
* @var string
*/
private $varPath;
@ -80,4 +80,8 @@ class SupportVectorMachine
{
return $this->model;
}
public function predict(array $samples)
{
}
}

View File

@ -14,10 +14,10 @@ class DataTransformerTest extends \PHPUnit_Framework_TestCase
$labels = ['a', 'a', 'b', 'b'];
$trainingSet =
'0 0:1 1:1 '.PHP_EOL.
'0 0:2 1:1 '.PHP_EOL.
'1 0:3 1:2 '.PHP_EOL.
'1 0:4 1:5 '.PHP_EOL
'0 1:1 2:1 '.PHP_EOL.
'0 1:2 2:1 '.PHP_EOL.
'1 1:3 2:2 '.PHP_EOL.
'1 1:4 2:5 '.PHP_EOL
;
$this->assertEquals($trainingSet, DataTransformer::trainingSet($samples, $labels));

View File

@ -24,8 +24,8 @@ rho 0
label 0 1
nr_sv 1 1
SV
0.25 0:2 1:4
-0.25 0:4 1:2
0.25 1:2 2:4
-0.25 1:4 2:2
';
$svm = new SupportVectorMachine(Type::C_SVC, Kernel::LINEAR, 100.0);