types.py 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. from collections import namedtuple
  3. from enum import Enum
  4. class Dataset(Enum):
  5. CMC = 'cmc'
  6. MGM = 'mgm'
  7. ADULT = 'adult'
  8. CAHOUSING = 'cahousing'
  9. def __str__(self):
  10. return self.value
  11. def __eq__(self, other):
  12. return str(other) == self.value
  13. class AnonMethod(Enum):
  14. OLA = 'ola'
  15. MONDRIAN = 'mondrian'
  16. TDG = 'tdg'
  17. CB = 'cb'
  18. def __str__(self):
  19. return self.value
  20. def __eq__(self, other):
  21. return str(other) == self.value
  22. class Classifier(Enum):
  23. RF = 'rf'
  24. KNN = 'knn'
  25. SVM = 'svm'
  26. XGB = 'xgb'
  27. def __str__(self):
  28. return self.value
  29. def __eq__(self, other):
  30. return str(other) == self.value
  31. MLRes = namedtuple("MLRes", ['acc', 'precision', 'recall', 'f1_score'])
  32. # python3.6
  33. MLRes.__new__.__defaults__ = (['accuracy'], ['precision'], ['recall'], ['f1'])