so_magic.data.dataset.Dataset.features()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import attr
2
3
4
@attr.s(str=True, repr=True)
5
class Dataset:
6
    """High level representation of data, of some form.
7
8
    Instances of this class encapsulate observations in the form of datapoints
9
    as well as their respective feature vectors. Feature vectors can then be
10
    trivially "fed" into a Machine Learning algorithm (eg SOM).
11
12
    Args:
13
        datapoints ():
14
        name (str, optional):
15
    Returns:
16
        [type]: [description]
17
    """
18
    datapoints = attr.ib(init=True)
19
    name = attr.ib(init=True, default=None)
20
21
    _features = attr.ib(init=True, default=[])
22
    size = attr.ib(init=False, default=attr.Factory(lambda self: len(self.datapoints) if self.datapoints else 0,
23
                                                    takes_self=True))
24
25
    @property
26
    def features(self):
27
        return self._features
28
29
    @features.setter
30
    def features(self, features):
31
        self._features = features
32