onehot_encoder_param.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright 2019 The FATE Authors. All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. from federatedml.param.base_param import BaseParam
  19. class OneHotEncoderParam(BaseParam):
  20. """
  21. Parameters
  22. ----------
  23. transform_col_indexes: list or int, default: -1
  24. Specify which columns need to calculated. -1 represent for all columns.
  25. transform_col_names : list of string, default: []
  26. Specify which columns need to calculated. Each element in the list represent for a column name in header.
  27. need_run: bool, default True
  28. Indicate if this module needed to be run
  29. """
  30. def __init__(self, transform_col_indexes=-1, transform_col_names=None, need_run=True):
  31. super(OneHotEncoderParam, self).__init__()
  32. if transform_col_names is None:
  33. transform_col_names = []
  34. self.transform_col_indexes = transform_col_indexes
  35. self.transform_col_names = transform_col_names
  36. self.need_run = need_run
  37. def check(self):
  38. descr = "One-hot encoder param's"
  39. self.check_defined_type(self.transform_col_indexes, descr, ['list', 'int', 'NoneType'])
  40. self.check_defined_type(self.transform_col_names, descr, ['list', 'NoneType'])
  41. return True