so_magic.data.encoding   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A EncoderInterface.encode() 0 3 1
1
from abc import ABC, abstractmethod
2
import attr
3
4
5
class EncoderInterface(ABC):
6
    @abstractmethod
7
    def encode(self, *args, **kwargs):
8
        raise NotImplementedError
9
10
11
@attr.s(slots=True)
12
class NominalAttributeEncoder(EncoderInterface, ABC):
13
    """Encode the observations of a categorical nominal variable.
14
15
    The client code can supply the possible values for the nominal variable, if known a priori.
16
    The possible values are stored in the 'values_set' attribute/property. If they are not supplied
17
    they should be computed at runtime (when running the encode method).
18
19
    It also defines and stores the string identifiers for each column produced in the 'columns attribute/property.
20
21
    Args:
22
        values_set (list): the possible values of the nominal variable observations, if known a priori
23
    """
24
    values_set: list = attr.ib(default=attr.Factory(list))
25
    columns: list = attr.ib(init=False, default=[])
26