(self, model, epoch)
:param model: model instance, which has predict function
        :param epoch: int, epoch idx for generating flow id
:param model: model instance, which has predict function
        :param epoch: int, epoch idx for generating flow id
: param model : model instance which has predict function : param epoch : int epoch idx for generating flow id
def validate(self, model, epoch):

        """
        :param model: model instance, which has predict function
        :param epoch: int, epoch idx for generating flow id
        """

        LOGGER.debug("begin to check validate status, need_run_validation is {}".format(self.need_run_validation(epoch)))

        if not self.need_run_validation(epoch):
            return

        if self.mode == consts.HOMO and self.role == consts.ARBITER:
            return

        if not self.use_precompute_train_scores:  # call model.predict()
            train_predicts = self.get_predict_result(model, epoch, self.train_data, "train")
        else:  # use precomputed scores
            train_predicts = self.handle_precompute_scores(self.cached_train_scores, 'train')

        if not self.use_precompute_validate_scores:  # call model.predict()
            validate_predicts = self.get_predict_result(model, epoch, self.validate_data, "validate")
        else:  # use precomputed scores
            validate_predicts = self.handle_precompute_scores(self.cached_validate_scores, 'validate')

        if train_predicts is not None or validate_predicts is not None:

            predicts = train_predicts
            if validate_predicts:
                predicts = predicts.union(validate_predicts)

            # running evaluation
            eval_result_dict = self.evaluate(predicts, model, epoch)
            LOGGER.debug('showing eval_result_dict here')
            LOGGER.debug(eval_result_dict)

            if self.early_stopping_rounds:

                if len(eval_result_dict) == 0:
                    raise ValueError("eval_result len is 0, no single value metric detected for early stopping checking")

                if self.use_first_metric_only:
                    if self.first_metric:
                        eval_result_dict = {self.first_metric: eval_result_dict[self.first_metric]}
                    else:
                        LOGGER.warning('use first metric only but no single metric found in metric list')

                self.performance_recorder.update(eval_result_dict)

        if self.sync_status:
            self.sync_performance_recorder(epoch)

        if self.early_stopping_rounds and self.mode == consts.HETERO:
            self.update_early_stopping_status(epoch, model)
def validate ( self , model , epoch ) : LOGGER . debug ( "begin to check validate status, need_run_validation is {}" . format ( self . need_run_validation ( epoch ) ) ) if not self . need_run_validation ( epoch ) : return if self . mode == consts . HOMO and self . role == consts . ARBITER : return if not self . use_precompute_train_scores : # call model.predict() train_predicts = self . get_predict_result ( model , epoch , self . train_data , "train" ) else : # use precomputed scores train_predicts = self . handle_precompute_scores ( self . cached_train_scores , 'train' ) if not self . use_precompute_validate_scores : # call model.predict() validate_predicts = self . get_predict_result ( model , epoch , self . validate_data , "validate" ) else : # use precomputed scores validate_predicts = self . handle_precompute_scores ( self . cached_validate_scores , 'validate' ) if train_predicts is not None or validate_predicts is not None : predicts = train_predicts if validate_predicts : predicts = predicts . union ( validate_predicts ) # running evaluation eval_result_dict = self . evaluate ( predicts , model , epoch ) LOGGER . debug ( 'showing eval_result_dict here' ) LOGGER . debug ( eval_result_dict ) if self . early_stopping_rounds : if len ( eval_result_dict ) == 0 : raise ValueError ( "eval_result len is 0, no single value metric detected for early stopping checking" ) if self . use_first_metric_only : if self . first_metric : eval_result_dict = { self . first_metric : eval_result_dict [ self . first_metric ] } else : LOGGER . warning ( 'use first metric only but no single metric found in metric list' ) self . performance_recorder . update ( eval_result_dict ) if self . sync_status : self . sync_performance_recorder ( epoch ) if self . early_stopping_rounds and self . mode == consts . HETERO : self . update_early_stopping_status ( epoch , model )