homo_onehot_encoder_param.py 1.3 KB

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