(self, data_instances)
return self.data_output
Apply binning method for both data instances in local party as well as the other one. Afterwards, calculate
        the specific metric value for specific columns. Currently, iv is support for binary labeled data only.
Apply binning method for both data instances in local party as well as the other one. Afterwards, calculate
        the specific metric value for specific columns. Currently, iv is support for binary labeled data only.
Apply binning method for both data instances in local party as well as the other one . Afterwards calculate the specific metric value for specific columns . Currently iv is support for binary labeled data only .
def fit(self, data_instances):
        """
        Apply binning method for both data instances in local party as well as the other one. Afterwards, calculate
        the specific metric value for specific columns. Currently, iv is support for binary labeled data only.
        """
        LOGGER.info("Start feature binning fit and transform")
        self._abnormal_detection(data_instances)

        # self._parse_cols(data_instances)

        self._setup_bin_inner_param(data_instances, self.model_param)

        if self.model_param.method == consts.OPTIMAL:
            has_missing_value = self.iv_calculator.check_containing_missing_value(data_instances)
            for idx in self.bin_inner_param.bin_indexes:
                if idx in has_missing_value:
                    raise ValueError(f"Optimal Binning do not support missing value now.")
        split_points = self.binning_obj.fit_split_points(data_instances)

        if self.model_param.skip_static:
            self.transform(data_instances)
            return self.data_output

        label_counts_dict = data_overview.get_label_count(data_instances)

        if len(label_counts_dict) > 2:
            if self.model_param.method == consts.OPTIMAL:
                raise ValueError("Have not supported optimal binning in multi-class data yet")

        self.labels = list(label_counts_dict.keys())
        label_counts = [label_counts_dict[k] for k in self.labels]
        label_table = IvCalculator.convert_label(data_instances, self.labels)
        self.bin_result = self.iv_calculator.cal_local_iv(data_instances=data_instances,
                                                          split_points=split_points,
                                                          labels=self.labels,
                                                          label_counts=label_counts,
                                                          bin_cols_map=self.bin_inner_param.get_need_cal_iv_cols_map(),
                                                          label_table=label_table)

        if self.model_param.local_only:

            self.transform(data_instances)
            self.set_summary(self.bin_result.summary())
            return self.data_output

        if self.model_param.encrypt_param.method == consts.PAILLIER:
            paillier_encryptor = PaillierEncrypt()
            paillier_encryptor.generate_key(self.model_param.encrypt_param.key_length)
            cipher = EncryptModeCalculator(encrypter=paillier_encryptor)
        else:
            raise NotImplementedError("encrypt method not supported yet")
        self._packer = GuestIntegerPacker(pack_num=len(self.labels), pack_num_range=label_counts,
                                          encrypt_mode_calculator=cipher)

        self.federated_iv(data_instances=data_instances, label_table=label_table,
                          cipher=cipher, result_counts=label_counts_dict, label_elements=self.labels)

        total_summary = self.bin_result.summary()
        for host_res in self.host_results:
            total_summary = self._merge_summary(total_summary, host_res.summary())

        self.set_schema(data_instances)
        self.transform(data_instances)
        LOGGER.info("Finish feature binning fit and transform")
        self.set_summary(total_summary)
        return self.data_output
def fit ( self , data_instances ) : LOGGER . info ( "Start feature binning fit and transform" ) self . _abnormal_detection ( data_instances ) # self._parse_cols(data_instances) self . _setup_bin_inner_param ( data_instances , self . model_param ) if self . model_param . method == consts . OPTIMAL : has_missing_value = self . iv_calculator . check_containing_missing_value ( data_instances ) for idx in self . bin_inner_param . bin_indexes : if idx in has_missing_value : raise ValueError ( f"Optimal Binning do not support missing value now." ) split_points = self . binning_obj . fit_split_points ( data_instances ) if self . model_param . skip_static : self . transform ( data_instances ) return self . data_output label_counts_dict = data_overview . get_label_count ( data_instances ) if len ( label_counts_dict ) > 2 : if self . model_param . method == consts . OPTIMAL : raise ValueError ( "Have not supported optimal binning in multi-class data yet" ) self . labels = list ( label_counts_dict . keys ( ) ) label_counts = [ label_counts_dict [ k ] for k in self . labels ] label_table = IvCalculator . convert_label ( data_instances , self . labels ) self . bin_result = self . iv_calculator . cal_local_iv ( data_instances = data_instances , split_points = split_points , labels = self . labels , label_counts = label_counts , bin_cols_map = self . bin_inner_param . get_need_cal_iv_cols_map ( ) , label_table = label_table ) if self . model_param . local_only : self . transform ( data_instances ) self . set_summary ( self . bin_result . summary ( ) ) return self . data_output if self . model_param . encrypt_param . method == consts . PAILLIER : paillier_encryptor = PaillierEncrypt ( ) paillier_encryptor . generate_key ( self . model_param . encrypt_param . key_length ) cipher = EncryptModeCalculator ( encrypter = paillier_encryptor ) else : raise NotImplementedError ( "encrypt method not supported yet" ) self . _packer = GuestIntegerPacker ( pack_num = len ( self . labels ) , pack_num_range = label_counts , encrypt_mode_calculator = cipher ) self . federated_iv ( data_instances = data_instances , label_table = label_table , cipher = cipher , result_counts = label_counts_dict , label_elements = self . labels ) total_summary = self . bin_result . summary ( ) for host_res in self . host_results : total_summary = self . _merge_summary ( total_summary , host_res . summary ( ) ) self . set_schema ( data_instances ) self . transform ( data_instances ) LOGGER . info ( "Finish feature binning fit and transform" ) self . set_summary ( total_summary ) return self . data_output