(self, data_instances, validate_data=None)
Train poisson model of role guest
        Parameters
        ----------
        data_instances: Table of Instance, input data
Train poisson model of role guest
        Parameters
        ----------
        data_instances: Table of Instance, input data
Train poisson model of role guest Parameters ---------- data_instances : Table of Instance input data
def fit(self, data_instances, validate_data=None):
        """
        Train poisson model of role guest
        Parameters
        ----------
        data_instances: Table of Instance, input data
        """

        LOGGER.info("Enter hetero_poisson_guest fit")
        self._abnormal_detection(data_instances)
        self.header = copy.deepcopy(self.get_header(data_instances))
        self.callback_list.on_train_begin(data_instances, validate_data)

        # self.validation_strategy = self.init_validation_strategy(data_instances, validate_data)
        if with_weight(data_instances):
            LOGGER.warning("input data with weight. Poisson regression does not support weighted training.")

        self.exposure_index = self.get_exposure_index(self.header, self.exposure_colname)
        exposure_index = self.exposure_index
        if exposure_index > -1:
            self.header.pop(exposure_index)
            LOGGER.info("Guest provides exposure value.")
        exposure = data_instances.mapValues(lambda v: HeteroPoissonBase.load_exposure(v, exposure_index))
        data_instances = data_instances.mapValues(lambda v: HeteroPoissonBase.load_instance(v, exposure_index))

        self.cipher_operator = self.cipher.gen_paillier_cipher_operator()

        LOGGER.info("Generate mini-batch from input data")
        self.batch_generator.initialize_batch_generator(data_instances, self.batch_size)
        self.encrypted_calculator = [EncryptModeCalculator(self.cipher_operator,
                                                           self.encrypted_mode_calculator_param.mode,
                                                           self.encrypted_mode_calculator_param.re_encrypted_rate) for _
                                     in range(self.batch_generator.batch_nums)]

        LOGGER.info("Start initialize model.")
        LOGGER.info("fit_intercept:{}".format(self.init_param_obj.fit_intercept))
        model_shape = self.get_features_shape(data_instances)
        if not self.component_properties.is_warm_start:
            w = self.initializer.init_model(model_shape, init_params=self.init_param_obj)
            self.model_weights = LinearModelWeights(w, fit_intercept=self.fit_intercept, raise_overflow_error=False)
        else:
            self.callback_warm_start_init_iter(self.n_iter_)

        while self.n_iter_ < self.max_iter:
            self.callback_list.on_epoch_begin(self.n_iter_)
            LOGGER.info("iter:{}".format(self.n_iter_))
            # each iter will get the same batch_data_generator
            batch_data_generator = self.batch_generator.generate_batch_data()
            self.optimizer.set_iters(self.n_iter_)
            batch_index = 0
            for batch_data in batch_data_generator:
                # compute offset of this batch
                batch_offset = exposure.join(batch_data, lambda ei, d: HeteroPoissonBase.safe_log(ei))

                # Start gradient procedure
                optimized_gradient = self.gradient_loss_operator.compute_gradient_procedure(
                    batch_data,
                    self.encrypted_calculator,
                    self.model_weights,
                    self.optimizer,
                    self.n_iter_,
                    batch_index,
                    batch_offset
                )
                # LOGGER.debug("iteration:{} Guest's gradient: {}".format(self.n_iter_, optimized_gradient))
                loss_norm = self.optimizer.loss_norm(self.model_weights)
                self.gradient_loss_operator.compute_loss(data_instances, self.model_weights, self.n_iter_,
                                                         batch_index, batch_offset, loss_norm)

                self.model_weights = self.optimizer.update_model(self.model_weights, optimized_gradient)

                batch_index += 1

            self.is_converged = self.converge_procedure.sync_converge_info(suffix=(self.n_iter_,))
            LOGGER.info("iter: {},  is_converged: {}".format(self.n_iter_, self.is_converged))

            self.callback_list.on_epoch_end(self.n_iter_)
            self.n_iter_ += 1

            if self.stop_training:
                break

            if self.is_converged:
                break
        self.callback_list.on_train_end()
        self.set_summary(self.get_model_summary())
def fit ( self , data_instances , validate_data = None ) : LOGGER . info ( "Enter hetero_poisson_guest fit" ) self . _abnormal_detection ( data_instances ) self . header = copy . deepcopy ( self . get_header ( data_instances ) ) self . callback_list . on_train_begin ( data_instances , validate_data ) # self.validation_strategy = self.init_validation_strategy(data_instances, validate_data) if with_weight ( data_instances ) : LOGGER . warning ( "input data with weight. Poisson regression does not support weighted training." ) self . exposure_index = self . get_exposure_index ( self . header , self . exposure_colname ) exposure_index = self . exposure_index if exposure_index > - 1 : self . header . pop ( exposure_index ) LOGGER . info ( "Guest provides exposure value." ) exposure = data_instances . mapValues ( lambda v : HeteroPoissonBase . load_exposure ( v , exposure_index ) ) data_instances = data_instances . mapValues ( lambda v : HeteroPoissonBase . load_instance ( v , exposure_index ) ) self . cipher_operator = self . cipher . gen_paillier_cipher_operator ( ) LOGGER . info ( "Generate mini-batch from input data" ) self . batch_generator . initialize_batch_generator ( data_instances , self . batch_size ) self . encrypted_calculator = [ EncryptModeCalculator ( self . cipher_operator , self . encrypted_mode_calculator_param . mode , self . encrypted_mode_calculator_param . re_encrypted_rate ) for _ in range ( self . batch_generator . batch_nums ) ] LOGGER . info ( "Start initialize model." ) LOGGER . info ( "fit_intercept:{}" . format ( self . init_param_obj . fit_intercept ) ) model_shape = self . get_features_shape ( data_instances ) if not self . component_properties . is_warm_start : w = self . initializer . init_model ( model_shape , init_params = self . init_param_obj ) self . model_weights = LinearModelWeights ( w , fit_intercept = self . fit_intercept , raise_overflow_error = False ) else : self . callback_warm_start_init_iter ( self . n_iter_ ) while self . n_iter_ < self . max_iter : self . callback_list . on_epoch_begin ( self . n_iter_ ) LOGGER . info ( "iter:{}" . format ( self . n_iter_ ) ) # each iter will get the same batch_data_generator batch_data_generator = self . batch_generator . generate_batch_data ( ) self . optimizer . set_iters ( self . n_iter_ ) batch_index = 0 for batch_data in batch_data_generator : # compute offset of this batch batch_offset = exposure . join ( batch_data , lambda ei , d : HeteroPoissonBase . safe_log ( ei ) ) # Start gradient procedure optimized_gradient = self . gradient_loss_operator . compute_gradient_procedure ( batch_data , self . encrypted_calculator , self . model_weights , self . optimizer , self . n_iter_ , batch_index , batch_offset ) # LOGGER.debug("iteration:{} Guest's gradient: {}".format(self.n_iter_, optimized_gradient)) loss_norm = self . optimizer . loss_norm ( self . model_weights ) self . gradient_loss_operator . compute_loss ( data_instances , self . model_weights , self . n_iter_ , batch_index , batch_offset , loss_norm ) self . model_weights = self . optimizer . update_model ( self . model_weights , optimized_gradient ) batch_index += 1 self . is_converged = self . converge_procedure . sync_converge_info ( suffix = ( self . n_iter_ , ) ) LOGGER . info ( "iter: {},  is_converged: {}" . format ( self . n_iter_ , self . is_converged ) ) self . callback_list . on_epoch_end ( self . n_iter_ ) self . n_iter_ += 1 if self . stop_training : break if self . is_converged : break self . callback_list . on_train_end ( ) self . set_summary ( self . get_model_summary ( ) )