| Total Complexity | 13 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import attr |
||
| 2 | |||
| 3 | from .types import NominalVariableType |
||
| 4 | from .features import TrackingFeature |
||
| 5 | |||
| 6 | @attr.s |
||
| 7 | class BaseFeatureSet: |
||
| 8 | features = attr.ib(init=True, default=[]) |
||
| 9 | |||
| 10 | def __len__(self): |
||
| 11 | return len(self.features) |
||
| 12 | |||
| 13 | def __getitem__(self, item): |
||
| 14 | return self.features[item] |
||
| 15 | |||
| 16 | def __iter__(self): |
||
| 17 | return iter(self.features) |
||
| 18 | |||
| 19 | @classmethod |
||
| 20 | def from_raw_extractors(cls, data): |
||
| 21 | """Create a Feature for each of the lists in the input data (list). Inner lists must satisfy 0 < len(l)""" |
||
| 22 | return [TrackingFeature.from_callable(*args) for args in data] |
||
| 23 | |||
| 24 | |||
| 25 | class FeatureSet(BaseFeatureSet): |
||
| 26 | |||
| 27 | @property |
||
| 28 | def encoded(self): |
||
| 29 | for feature in self.features: |
||
| 30 | if str(feature.state) == 'encoded': |
||
| 31 | yield feature |
||
| 32 | |||
| 33 | @property |
||
| 34 | def not_encoded(self): |
||
| 35 | for feature in self.features: |
||
| 36 | if str(feature.state) != 'encoded': |
||
| 37 | yield feature |
||
| 38 | |||
| 39 | @property |
||
| 40 | def binnable(self): |
||
| 41 | for feature in self.features: |
||
| 42 | if not isinstance(feature.var_type, NominalVariableType): |
||
| 43 | yield feature |
||
| 44 |