(self, bin_indices)
return distributions
Compute the distribution of instances within bins.

        Parameters
        ----------
        bin_indices : np.ndarray
            An array with same shape as `x` but containing the bin index of the
            instance.

        Returns
        -------
        np.ndarray
            A 2d array; the first dimension represents different bins, the
            second - the counts of different target values.
Compute the distribution of instances within bins.
Compute the distribution of instances within bins .
def _get_bin_distributions(self, bin_indices):
        """Compute the distribution of instances within bins.

        Parameters
        ----------
        bin_indices : np.ndarray
            An array with same shape as `x` but containing the bin index of the
            instance.

        Returns
        -------
        np.ndarray
            A 2d array; the first dimension represents different bins, the
            second - the counts of different target values.

        """
        if self.target_var and self.target_var.is_discrete:
            y = self.y
            # TODO This probably also isn't the best handling of sparse data...
            if sp.issparse(y):
                y = np.squeeze(np.array(y.todense()))

            # Since y can contain missing values, we need to filter them out as
            # well as their corresponding `x` values
            y_nan_mask = np.isnan(y)
            y, bin_indices = y[~y_nan_mask], bin_indices[~y_nan_mask]
            y = one_hot(y, dim=len(self.target_var.values))

            bins = np.arange(self.n_bins)[:, np.newaxis]
            mask = bin_indices == bins
            distributions = np.zeros((self.n_bins, y.shape[1]))
            for bin_idx in range(self.n_bins):
                distributions[bin_idx] = y[mask[bin_idx]].sum(axis=0)
        else:
            distributions, _ = ut.bincount(bin_indices.astype(np.int64))
            # To keep things consistent across different variable types, we
            # want to return a 2d array where the first dim represent different
            # bins, and the second the distributions.
            distributions = distributions[:, np.newaxis]

        return distributions
def _get_bin_distributions ( self , bin_indices ) : if self . target_var and self . target_var . is_discrete : y = self . y # TODO This probably also isn't the best handling of sparse data... if sp . issparse ( y ) : y = np . squeeze ( np . array ( y . todense ( ) ) ) # Since y can contain missing values, we need to filter them out as # well as their corresponding `x` values y_nan_mask = np . isnan ( y ) y , bin_indices = y [ ~ y_nan_mask ] , bin_indices [ ~ y_nan_mask ] y = one_hot ( y , dim = len ( self . target_var . values ) ) bins = np . arange ( self . n_bins ) [ : , np . newaxis ] mask = bin_indices == bins distributions = np . zeros ( ( self . n_bins , y . shape [ 1 ] ) ) for bin_idx in range ( self . n_bins ) : distributions [ bin_idx ] = y [ mask [ bin_idx ] ] . sum ( axis = 0 ) else : distributions , _ = ut . bincount ( bin_indices . astype ( np . int64 ) ) # To keep things consistent across different variable types, we # want to return a 2d array where the first dim represent different # bins, and the second the distributions. distributions = distributions [ : , np . newaxis ] return distributions