public function testPredictSampleFromMultipleClassWithRbfKernel()
 {
     $samples = [[1, 3], [1, 4], [1, 4], [3, 1], [4, 1], [4, 2], [-3, -1], [-4, -1], [-4, -2]];
     $labels = ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'];
     $svm = new SupportVectorMachine(Type::C_SVC, Kernel::RBF, 100.0);
     $svm->train($samples, $labels);
     $predictions = $svm->predict([[1, 5], [4, 3], [-4, -3]]);
     $this->assertEquals('a', $predictions[0]);
     $this->assertEquals('b', $predictions[1]);
     $this->assertEquals('c', $predictions[2]);
 }
Example #2
0
 /**
  * @param int        $kernel
  * @param int        $degree
  * @param float      $epsilon
  * @param float      $cost
  * @param float|null $gamma
  * @param float      $coef0
  * @param float      $tolerance
  * @param int        $cacheSize
  * @param bool       $shrinking
  */
 public function __construct(int $kernel = Kernel::RBF, int $degree = 3, float $epsilon = 0.1, float $cost = 1.0, float $gamma = null, float $coef0 = 0.0, float $tolerance = 0.001, int $cacheSize = 100, bool $shrinking = true)
 {
     parent::__construct(Type::EPSILON_SVR, $kernel, $cost, 0.5, $degree, $gamma, $coef0, $epsilon, $tolerance, $cacheSize, $shrinking, false);
 }
Example #3
0
 /**
  * @param int        $kernel
  * @param float      $cost
  * @param int        $degree
  * @param float|null $gamma
  * @param float      $coef0
  * @param float      $tolerance
  * @param int        $cacheSize
  * @param bool       $shrinking
  * @param bool       $probabilityEstimates
  */
 public function __construct(int $kernel = Kernel::LINEAR, float $cost = 1.0, int $degree = 3, float $gamma = null, float $coef0 = 0.0, float $tolerance = 0.001, int $cacheSize = 100, bool $shrinking = true, bool $probabilityEstimates = false)
 {
     parent::__construct(Type::C_SVC, $kernel, $cost, 0.5, $degree, $gamma, $coef0, 0.1, $tolerance, $cacheSize, $shrinking, $probabilityEstimates);
 }