php-ml/src/Phpml/Classifier/SupportVectorMachine.php

62 lines
1.1 KiB
PHP
Raw Normal View History

2016-04-19 20:54:33 +00:00
<?php
declare (strict_types = 1);
namespace Phpml\Classifier;
use Phpml\Classifier\Traits\Predictable;
use Phpml\Classifier\Traits\Trainable;
2016-04-21 21:21:08 +00:00
use Phpml\Math\Kernel;
2016-04-19 20:54:33 +00:00
class SupportVectorMachine implements Classifier
{
use Trainable, Predictable;
2016-04-20 21:56:33 +00:00
/**
2016-04-21 21:21:08 +00:00
* @var Kernel
2016-04-20 21:56:33 +00:00
*/
2016-04-21 21:21:08 +00:00
private $kernel;
2016-04-20 21:56:33 +00:00
/**
* @var float
*/
2016-04-21 21:21:08 +00:00
private $C;
2016-04-20 21:56:33 +00:00
/**
* @var float
*/
private $tolerance;
/**
* @var int
*/
private $upperBound;
/**
2016-04-21 21:21:08 +00:00
* @param Kernel $kernel
* @param float $C
2016-04-20 21:56:33 +00:00
* @param float $tolerance
* @param int $upperBound
*/
2016-04-21 21:21:08 +00:00
public function __construct(Kernel $kernel = null, float $C = 1.0, float $tolerance = .001, int $upperBound = 100)
2016-04-20 21:56:33 +00:00
{
2016-04-21 21:21:08 +00:00
if (null === $kernel) {
$kernel = new Kernel\RBF($gamma = .001);
}
$this->kernel = $kernel;
$this->C = $C;
2016-04-20 21:56:33 +00:00
$this->tolerance = $tolerance;
$this->upperBound = $upperBound;
}
2016-04-19 20:54:33 +00:00
/**
* @param array $sample
*
* @return mixed
*/
protected function predictSample(array $sample)
{
}
}