svm is hard :(

This commit is contained in:
Arkadiusz Kondas 2016-04-21 23:21:08 +02:00
parent 37782eba98
commit 118ee0b5fe

View File

@ -6,20 +6,21 @@ namespace Phpml\Classifier;
use Phpml\Classifier\Traits\Predictable;
use Phpml\Classifier\Traits\Trainable;
use Phpml\Math\Kernel;
class SupportVectorMachine implements Classifier
{
use Trainable, Predictable;
/**
* @var float
* @var Kernel
*/
private $gamma;
private $kernel;
/**
* @var float
*/
private $epsilon;
private $C;
/**
* @var float
@ -32,20 +33,23 @@ class SupportVectorMachine implements Classifier
private $upperBound;
/**
* @param float $gamma
* @param float $epsilon
* @param Kernel $kernel
* @param float $C
* @param float $tolerance
* @param int $upperBound
*/
public function __construct(float $gamma = .5, float $epsilon = .001, float $tolerance = .001, int $upperBound = 100)
public function __construct(Kernel $kernel = null, float $C = 1.0, float $tolerance = .001, int $upperBound = 100)
{
$this->gamma = $gamma;
$this->epsilon = $epsilon;
if (null === $kernel) {
$kernel = new Kernel\RBF($gamma = .001);
}
$this->kernel = $kernel;
$this->C = $C;
$this->tolerance = $tolerance;
$this->upperBound = $upperBound;
}
/**
* @param array $sample
*