1 | <?php |
||
9 | class Imputer implements Preprocessor |
||
10 | { |
||
11 | const AXIS_COLUMN = 0; |
||
12 | const AXIS_ROW = 1; |
||
13 | |||
14 | /** |
||
15 | * @var mixed |
||
16 | */ |
||
17 | private $missingValue; |
||
18 | |||
19 | /** |
||
20 | * @var Strategy |
||
21 | */ |
||
22 | private $strategy; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | private $axis; |
||
28 | |||
29 | /** |
||
30 | * @param mixed $missingValue |
||
31 | * @param Strategy $strategy |
||
32 | * @param int $axis |
||
33 | */ |
||
34 | public function __construct($missingValue = null, Strategy $strategy, int $axis = self::AXIS_COLUMN) |
||
40 | |||
41 | /** |
||
42 | * @param array $samples |
||
43 | */ |
||
44 | public function transform(array &$samples) |
||
45 | { |
||
46 | foreach ($samples as &$sample) { |
||
47 | $this->preprocessSample($sample, $samples); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param array $sample |
||
53 | * @param array $samples |
||
54 | */ |
||
55 | private function preprocessSample(array &$sample, array $samples) |
||
63 | |||
64 | /** |
||
65 | * @param int $column |
||
66 | * @param array $currentSample |
||
67 | * @param array $samples |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | private function getAxis(int $column, array $currentSample, array $samples): array |
||
86 | } |
||
87 |