(cls, predict_proba)
return entropy
Calc the entropy for each instance.

        Parameters
        ----------
        predict_proba: array-like, shape [n_samples, n_class]
            Probability prediction for each instance.

        Returns
        -------
        entropy: list
            1d array, entropy for each instance.
Calc the entropy for each instance.
Calc the entropy for each instance .
def calc_entropy(cls, predict_proba):
        """Calc the entropy for each instance.

        Parameters
        ----------
        predict_proba: array-like, shape [n_samples, n_class]
            Probability prediction for each instance.

        Returns
        -------
        entropy: list
            1d array, entropy for each instance.
        """
        pv = np.asarray(predict_proba)
        spv = np.shape(pv)
        if len(spv) != 2 or spv[1] == 1:
            raise Exception('2d array with the shape [n_samples, n_classes]'
                            ' is expected, but received shape: \n%s' % str(spv))
        # calc entropy
        entropy = [-np.sum(vec * np.log(vec+1e-9)) for vec in pv]
        return entropy
def calc_entropy ( cls , predict_proba ) : pv = np . asarray ( predict_proba ) spv = np . shape ( pv ) if len ( spv ) != 2 or spv [ 1 ] == 1 : raise Exception ( '2d array with the shape [n_samples, n_classes]' ' is expected, but received shape: \n%s' % str ( spv ) ) # calc entropy entropy = [ - np . sum ( vec * np . log ( vec + 1e-9 ) ) for vec in pv ] return entropy