psi_param.py 1.0 KB

123456789101112131415161718192021222324
  1. from federatedml.param.base_param import BaseParam
  2. from federatedml.util import consts
  3. class PSIParam(BaseParam):
  4. def __init__(self, max_bin_num=20, need_run=True, dense_missing_val=None,
  5. binning_error=consts.DEFAULT_RELATIVE_ERROR):
  6. super(PSIParam, self).__init__()
  7. self.max_bin_num = max_bin_num
  8. self.need_run = need_run
  9. self.dense_missing_val = dense_missing_val
  10. self.binning_error = binning_error
  11. def check(self):
  12. assert isinstance(self.max_bin_num, int) and self.max_bin_num > 0, 'max bin must be an integer larger than 0'
  13. assert isinstance(self.need_run, bool)
  14. if self.dense_missing_val is not None:
  15. assert isinstance(self.dense_missing_val, str) or isinstance(self.dense_missing_val, int) or \
  16. isinstance(self.dense_missing_val, float), \
  17. 'missing value type {} not supported'.format(type(self.dense_missing_val))
  18. self.check_decimal_float(self.binning_error, "psi's param")