1 | <?php |
||
11 | class LeastSquares implements Regression |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | private $features; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | private $targets; |
||
22 | |||
23 | /** |
||
24 | * @var float |
||
25 | */ |
||
26 | private $slope; |
||
27 | |||
28 | /** |
||
29 | * @var |
||
30 | */ |
||
31 | private $intercept; |
||
32 | |||
33 | /** |
||
34 | * @param array $features |
||
35 | * @param array $targets |
||
36 | */ |
||
37 | public function train(array $features, array $targets) |
||
45 | |||
46 | /** |
||
47 | * @param float $feature |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function predict($feature) |
||
55 | |||
56 | private function computeSlope() |
||
64 | |||
65 | private function computeIntercept() |
||
72 | } |
||
73 |