Passed
Pull Request — master (#78)
by
unknown
04:36
created

PartiallyTrainable::train()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Phpml\Helper;
6
7
trait PartiallyTrainable
8
{
9
10
    /**
11
     * @param array $samples
12
     * @param array $targets
13
     */
14
    public function train(array $samples, array $targets)
15
    {
16
17
        // Clears previous labels and classifiers.
18
        $this->resetTrainer();
19
20
        return $this->partialTrain($samples, $targets);
21
    }
22
23
    /**
24
     * @param array $samples
25
     * @param array $targets
26
     * @param array $labels
27
     */
28
    abstract public function partialTrain(array $samples, array $targets, array $labels = array());
29
30
    /**
31
     * Clear the trainer before training again.
32
     */
33
    abstract protected function resetTrainer();
34
}
35