(self)
return corr
Computes the correlations between attributes by calculating
        the normalized conditional entropy between them. The conditional
        entropy is asymmetric, therefore we need pairwise computation.

        The computed correlations are stored in a dictionary in the format:
        {
          attr_a: { cond_attr_i: corr_strength_a_i,
                    cond_attr_j: corr_strength_a_j, ... },
          attr_b: { cond_attr_i: corr_strength_b_i, ...}
        }

        :return a dictionary of correlations
Computes the correlations between attributes by calculating
        the normalized conditional entropy between them. The conditional
        entropy is asymmetric, therefore we need pairwise computation.
Computes the correlations between attributes by calculating the normalized conditional entropy between them . The conditional entropy is asymmetric therefore we need pairwise computation .
def _compute_norm_cond_entropy_corr(self):
        """
        Computes the correlations between attributes by calculating
        the normalized conditional entropy between them. The conditional
        entropy is asymmetric, therefore we need pairwise computation.

        The computed correlations are stored in a dictionary in the format:
        {
          attr_a: { cond_attr_i: corr_strength_a_i,
                    cond_attr_j: corr_strength_a_j, ... },
          attr_b: { cond_attr_i: corr_strength_b_i, ...}
        }

        :return a dictionary of correlations
        """
        data_df = self.ds.get_raw_data()
        attrs = self.ds.get_attributes()

        corr = {}
        # Compute pair-wise conditional entropy.
        for x in attrs:
            corr[x] = {}
            x_vals = data_df[x]
            x_domain_size = x_vals.nunique()
            for y in attrs:
                # Set correlation to 0.0 if entropy of x is 1 (only one possible value).
                if x_domain_size == 1:
                    corr[x][y] = 0.0
                    continue

                # Set correlation to 1 for same attributes.
                if x == y:
                    corr[x][y] = 1.0
                    continue

                # Compute the conditional entropy H(x|y) = H(x,y) - H(y).
                # H(x,y) denotes H(x U y).
                # If H(x|y) = 0, then y determines x, i.e., y -> x.
                # Use the domain size of x as a log base for normalization.
                y_vals = data_df[y]
                x_y_entropy = drv.entropy_conditional(x_vals, y_vals, base=x_domain_size)

                # The conditional entropy is 0 for strongly correlated attributes and 1 for
                # completely independent attributes. We reverse this to reflect the correlation.
                corr[x][y] = 1.0 - x_y_entropy
        return corr
def _compute_norm_cond_entropy_corr ( self ) : data_df = self . ds . get_raw_data ( ) attrs = self . ds . get_attributes ( ) corr = { } # Compute pair-wise conditional entropy. for x in attrs : corr [ x ] = { } x_vals = data_df [ x ] x_domain_size = x_vals . nunique ( ) for y in attrs : # Set correlation to 0.0 if entropy of x is 1 (only one possible value). if x_domain_size == 1 : corr [ x ] [ y ] = 0.0 continue # Set correlation to 1 for same attributes. if x == y : corr [ x ] [ y ] = 1.0 continue # Compute the conditional entropy H(x|y) = H(x,y) - H(y). # H(x,y) denotes H(x U y). # If H(x|y) = 0, then y determines x, i.e., y -> x. # Use the domain size of x as a log base for normalization. y_vals = data_df [ y ] x_y_entropy = drv . entropy_conditional ( x_vals , y_vals , base = x_domain_size ) # The conditional entropy is 0 for strongly correlated attributes and 1 for # completely independent attributes. We reverse this to reflect the correlation. corr [ x ] [ y ] = 1.0 - x_y_entropy return corr