| Total Complexity | 1 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 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 |