mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-25 14:27:34 +00:00
fix index for trainging set
This commit is contained in:
parent
95caef8692
commit
4ac2ac8a35
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user