(self, data_instances, fore_gradient, fit_intercept)
return gradient
Compute hetero-regression gradient
        Parameters
        ----------
        data_instances: Table, input data
        fore_gradient: Table, fore_gradient
        fit_intercept: bool, if model has intercept or not

        Returns
        ----------
        Table
            the hetero regression model's gradient
Compute hetero-regression gradient
        Parameters
        ----------
        data_instances: Table, input data
        fore_gradient: Table, fore_gradient
        fit_intercept: bool, if model has intercept or not
Compute hetero - regression gradient Parameters ---------- data_instances : Table input data fore_gradient : Table fore_gradient fit_intercept : bool if model has intercept or not
def compute_gradient(self, data_instances, fore_gradient, fit_intercept):
        """
        Compute hetero-regression gradient
        Parameters
        ----------
        data_instances: Table, input data
        fore_gradient: Table, fore_gradient
        fit_intercept: bool, if model has intercept or not

        Returns
        ----------
        Table
            the hetero regression model's gradient
        """

        feature_num = data_overview.get_features_shape(data_instances)
        data_count = data_instances.count()
        is_sparse = data_overview.is_sparse_data(data_instances)

        if data_count * feature_num > 100:
            LOGGER.debug("Use apply partitions")
            feat_join_grad = data_instances.join(fore_gradient,
                                                 lambda d, g: (d.features, g))
            f = functools.partial(self.__apply_cal_gradient,
                                  fixed_point_encoder=self.fixed_point_encoder,
                                  is_sparse=is_sparse)
            gradient_sum = feat_join_grad.applyPartitions(f)
            gradient_sum = gradient_sum.reduce(lambda x, y: x + y)
            if fit_intercept:
                # bias_grad = np.sum(fore_gradient)
                bias_grad = fore_gradient.reduce(lambda x, y: x + y)
                gradient_sum = np.append(gradient_sum, bias_grad)
            gradient = gradient_sum / data_count

        else:
            LOGGER.debug(f"Original_method")
            feat_join_grad = data_instances.join(fore_gradient,
                                                 lambda d, g: (d.features, g))
            f = functools.partial(self.__compute_partition_gradient,
                                  fit_intercept=fit_intercept,
                                  is_sparse=is_sparse)
            gradient_partition = feat_join_grad.applyPartitions(f)
            gradient_partition = gradient_partition.reduce(lambda x, y: x + y)

            gradient = gradient_partition / data_count

        return gradient
def compute_gradient ( self , data_instances , fore_gradient , fit_intercept ) : feature_num = data_overview . get_features_shape ( data_instances ) data_count = data_instances . count ( ) is_sparse = data_overview . is_sparse_data ( data_instances ) if data_count * feature_num > 100 : LOGGER . debug ( "Use apply partitions" ) feat_join_grad = data_instances . join ( fore_gradient , lambda d , g : ( d . features , g ) ) f = functools . partial ( self . __apply_cal_gradient , fixed_point_encoder = self . fixed_point_encoder , is_sparse = is_sparse ) gradient_sum = feat_join_grad . applyPartitions ( f ) gradient_sum = gradient_sum . reduce ( lambda x , y : x + y ) if fit_intercept : # bias_grad = np.sum(fore_gradient) bias_grad = fore_gradient . reduce ( lambda x , y : x + y ) gradient_sum = np . append ( gradient_sum , bias_grad ) gradient = gradient_sum / data_count else : LOGGER . debug ( f"Original_method" ) feat_join_grad = data_instances . join ( fore_gradient , lambda d , g : ( d . features , g ) ) f = functools . partial ( self . __compute_partition_gradient , fit_intercept = fit_intercept , is_sparse = is_sparse ) gradient_partition = feat_join_grad . applyPartitions ( f ) gradient_partition = gradient_partition . reduce ( lambda x , y : x + y ) gradient = gradient_partition / data_count return gradient