(self, data_inst, y_hat)
return predict_result
given binary/multi-class/regression prediction scores, outputs result in standard format
given binary/multi-class/regression prediction scores, outputs result in standard format
given binary / multi - class / regression prediction scores outputs result in standard format
def score_to_predict_result(self, data_inst, y_hat):
        """
        given binary/multi-class/regression prediction scores, outputs result in standard format
        """
        predicts = None
        if self.task_type == consts.CLASSIFICATION:
            loss_method = self.loss
            if self.num_classes == 2:
                predicts = y_hat.mapValues(lambda f: float(loss_method.predict(f)))
            else:
                predicts = y_hat.mapValues(lambda f: loss_method.predict(f).tolist())

        elif self.task_type == consts.REGRESSION:
            if self.objective_param.objective in ["lse", "lae", "huber", "log_cosh", "fair", "tweedie"]:
                predicts = y_hat
            else:
                raise NotImplementedError("objective {} not supprted yet".format(self.objective_param.objective))

        if self.task_type == consts.CLASSIFICATION:

            predict_result = self.predict_score_to_output(data_inst, predict_score=predicts, classes=self.classes_,
                                                          threshold=self.predict_param.threshold)

        elif self.task_type == consts.REGRESSION:
            predicts = predicts.mapValues(lambda x: x[0])
            predict_result = self.predict_score_to_output(data_inst, predict_score=predicts, classes=None)

        else:
            raise NotImplementedError("task type {} not supported yet".format(self.task_type))
        return predict_result
def score_to_predict_result ( self , data_inst , y_hat ) : predicts = None if self . task_type == consts . CLASSIFICATION : loss_method = self . loss if self . num_classes == 2 : predicts = y_hat . mapValues ( lambda f : float ( loss_method . predict ( f ) ) ) else : predicts = y_hat . mapValues ( lambda f : loss_method . predict ( f ) . tolist ( ) ) elif self . task_type == consts . REGRESSION : if self . objective_param . objective in [ "lse" , "lae" , "huber" , "log_cosh" , "fair" , "tweedie" ] : predicts = y_hat else : raise NotImplementedError ( "objective {} not supprted yet" . format ( self . objective_param . objective ) ) if self . task_type == consts . CLASSIFICATION : predict_result = self . predict_score_to_output ( data_inst , predict_score = predicts , classes = self . classes_ , threshold = self . predict_param . threshold ) elif self . task_type == consts . REGRESSION : predicts = predicts . mapValues ( lambda x : x [ 0 ] ) predict_result = self . predict_score_to_output ( data_inst , predict_score = predicts , classes = None ) else : raise NotImplementedError ( "task type {} not supported yet" . format ( self . task_type ) ) return predict_result