AbstractNormalization   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeDataset() 0 14 2
normalizeValue() 0 1 ?
1
<?php
2
3
namespace MachineLearning\Application\Normalization;
4
5
use MachineLearning\Domain\Model\Dataset;
6
use MachineLearning\Domain\Model\ValueInterface;
7
8
9
abstract class AbstractNormalization implements NormalizationInterface
10
{
11
    /**
12
     * @inheritdoc
13
     */
14 1
    public function normalizeDataset(Dataset $data, ValueInterface $coefficient)
15
    {
16 1
        $normalizedData = [];
17 1
        foreach ($data as $row) {
18 1
            $features = $row->getIndependentVariable();
19 1
            $features = $this->normalizeValue($features, $coefficient);
20 1
            $normalizedData[] = [
21 1
                $features->getValue(),
22 1
                $row->getDependentVariable()->getValue()
23 1
            ];
24 1
        }
25
26 1
        return new Dataset($normalizedData, $data->getHypothesis());
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    abstract public function normalizeValue(ValueInterface $value, ValueInterface $coefficient);
33
}