homo_onehot_encoder_param.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # added by jsweng
  5. # param class for OHE with alignment
  6. #
  7. from pipeline.param.base_param import BaseParam
  8. from pipeline.param import consts
  9. class HomoOneHotParam(BaseParam):
  10. """
  11. Parameters
  12. ----------
  13. transform_col_indexes: list or int, default: -1
  14. Specify which columns need to calculated. -1 represent for all columns.
  15. need_run: bool, default True
  16. Indicate if this module needed to be run
  17. need_alignment: bool, default True
  18. Indicated whether alignment of features is turned on
  19. """
  20. def __init__(self, transform_col_indexes=-1, transform_col_names=None, need_run=True, need_alignment=True):
  21. super(HomoOneHotParam, self).__init__()
  22. if transform_col_names is None:
  23. transform_col_names = []
  24. self.transform_col_indexes = transform_col_indexes
  25. self.transform_col_names = transform_col_names
  26. self.need_run = need_run
  27. self.need_alignment = need_alignment
  28. def check(self):
  29. descr = "One-hot encoder with alignment param's"
  30. self.check_defined_type(self.transform_col_indexes, descr, ['list', 'int'])
  31. self.check_boolean(self.need_run, descr)
  32. self.check_boolean(self.need_alignment, descr)
  33. return True