Completed
Push — develop ( 633974...f7b91b )
by Arkadiusz
02:36
created

SupportVectorMachine   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 51
wmc 3
lcom 0
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A predictSample() 0 3 1
1
<?php
2
3
declare (strict_types = 1);
4
5
namespace Phpml\Classification;
6
7
use Phpml\Classification\Traits\Predictable;
8
use Phpml\Classification\Traits\Trainable;
9
use Phpml\Math\Kernel;
10
11
class SupportVectorMachine implements Classifier
12
{
13
    use Trainable, Predictable;
14
15
    /**
16
     * @var Kernel
17
     */
18
    private $kernel;
19
20
    /**
21
     * @var float
22
     */
23
    private $C;
24
25
    /**
26
     * @var float
27
     */
28
    private $tolerance;
29
30
    /**
31
     * @var int
32
     */
33
    private $upperBound;
34
35
    /**
36
     * @param Kernel $kernel
37
     * @param float  $C
38
     * @param float  $tolerance
39
     * @param int    $upperBound
40
     */
41
    public function __construct(Kernel $kernel = null, float $C = 1.0, float $tolerance = .001, int $upperBound = 100)
42
    {
43
        if (null === $kernel) {
44
            $kernel = new Kernel\RBF($gamma = .001);
45
        }
46
47
        $this->kernel = $kernel;
48
        $this->C = $C;
49
        $this->tolerance = $tolerance;
50
        $this->upperBound = $upperBound;
51
    }
52
53
    /**
54
     * @param array $sample
55
     *
56
     * @return mixed
57
     */
58
    protected function predictSample(array $sample)
0 ignored issues
show
Unused Code introduced by
The parameter $sample is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
    }
61
}
62