so_magic.data.encoding.EncoderInterface.encode()   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 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
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