(self, y_hat, y)
return float(loss)
compute loss given predicted y and real y
compute loss given predicted y and real y
compute loss given predicted y and real y
def compute_loss(self, y_hat, y):
        """
        compute loss given predicted y and real y
        """
        LOGGER.info("compute loss")
        if self.task_type == consts.CLASSIFICATION:
            loss_method = self.loss
            y_predict = y_hat.mapValues(lambda val: loss_method.predict(val))
            loss = loss_method.compute_loss(y, y_predict)
        elif self.task_type == consts.REGRESSION:
            if self.objective_param.objective in ["lse", "lae", "logcosh", "tweedie", "log_cosh", "huber"]:
                loss_method = self.loss
                loss = loss_method.compute_loss(y, y_hat)
            else:
                loss_method = self.loss
                y_predict = y_hat.mapValues(lambda val: loss_method.predict(val))
                loss = loss_method.compute_loss(y, y_predict)

        return float(loss)
def compute_loss ( self , y_hat , y ) : LOGGER . info ( "compute loss" ) if self . task_type == consts . CLASSIFICATION : loss_method = self . loss y_predict = y_hat . mapValues ( lambda val : loss_method . predict ( val ) ) loss = loss_method . compute_loss ( y , y_predict ) elif self . task_type == consts . REGRESSION : if self . objective_param . objective in [ "lse" , "lae" , "logcosh" , "tweedie" , "log_cosh" , "huber" ] : loss_method = self . loss loss = loss_method . compute_loss ( y , y_hat ) else : loss_method = self . loss y_predict = y_hat . mapValues ( lambda val : loss_method . predict ( val ) ) loss = loss_method . compute_loss ( y , y_predict ) return float ( loss )