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

PartiallyTrainable   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A train() 0 8 1
partialTrain() 0 1 ?
resetTrainer() 0 1 ?
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