(cls, predict_matrices)
return score
Calculate the vote entropy for measuring the level of disagreement in QBC.

        Parameters
        ----------
        predict_matrices: list
            The prediction matrix for each committee.
            Each committee predict matrix should have the shape [n_samples, n_classes] for probabilistic output
            or [n_samples] for class output.

        Returns
        -------
        score: list
            Score for each instance. Shape [n_samples]

        References
        ----------
        [1] I. Dagan and S. Engelson. Committee-based sampling for training probabilistic
            classifiers. In Proceedings of the International Conference on Machine
            Learning (ICML), pages 150-157. Morgan Kaufmann, 1995.
Calculate the vote entropy for measuring the level of disagreement in QBC.
Calculate the vote entropy for measuring the level of disagreement in QBC .
def calc_vote_entropy(cls, predict_matrices):
        """Calculate the vote entropy for measuring the level of disagreement in QBC.

        Parameters
        ----------
        predict_matrices: list
            The prediction matrix for each committee.
            Each committee predict matrix should have the shape [n_samples, n_classes] for probabilistic output
            or [n_samples] for class output.

        Returns
        -------
        score: list
            Score for each instance. Shape [n_samples]

        References
        ----------
        [1] I. Dagan and S. Engelson. Committee-based sampling for training probabilistic
            classifiers. In Proceedings of the International Conference on Machine
            Learning (ICML), pages 150-157. Morgan Kaufmann, 1995.
        """
        score = []
        input_shape, committee_size = cls()._check_committee_results(predict_matrices)
        if len(input_shape) == 2:
            ele_uni = np.unique(predict_matrices)
            if not (len(ele_uni) == 2 and 0 in ele_uni and 1 in ele_uni):
                raise ValueError("The predicted label matrix must only contain 0 and 1")
            # calc each instance
            for i in range(input_shape[0]):
                instance_mat = np.array([X[i, :] for X in predict_matrices if X is not None])
                voting = np.sum(instance_mat, axis=0)
                tmp = 0
                # calc each label
                for vote in voting:
                    if vote != 0:
                        tmp += vote / len(predict_matrices) * np.log((vote+1e-9) / len(predict_matrices))
                score.append(-tmp)
        else:
            input_mat = np.array([X for X in predict_matrices if X is not None])
            # label_arr = np.unique(input_mat)
            # calc each instance's score
            for i in range(input_shape[0]):
                count_dict = collections.Counter(input_mat[:, i])
                tmp = 0
                for key in count_dict:
                    tmp += count_dict[key] / committee_size * np.log((count_dict[key]+1e-9) / committee_size)
                score.append(-tmp)
        return score
def calc_vote_entropy ( cls , predict_matrices ) : score = [ ] input_shape , committee_size = cls ( ) . _check_committee_results ( predict_matrices ) if len ( input_shape ) == 2 : ele_uni = np . unique ( predict_matrices ) if not ( len ( ele_uni ) == 2 and 0 in ele_uni and 1 in ele_uni ) : raise ValueError ( "The predicted label matrix must only contain 0 and 1" ) # calc each instance for i in range ( input_shape [ 0 ] ) : instance_mat = np . array ( [ X [ i , : ] for X in predict_matrices if X is not None ] ) voting = np . sum ( instance_mat , axis = 0 ) tmp = 0 # calc each label for vote in voting : if vote != 0 : tmp += vote / len ( predict_matrices ) * np . log ( ( vote + 1e-9 ) / len ( predict_matrices ) ) score . append ( - tmp ) else : input_mat = np . array ( [ X for X in predict_matrices if X is not None ] ) # label_arr = np.unique(input_mat) # calc each instance's score for i in range ( input_shape [ 0 ] ) : count_dict = collections . Counter ( input_mat [ : , i ] ) tmp = 0 for key in count_dict : tmp += count_dict [ key ] / committee_size * np . log ( ( count_dict [ key ] + 1e-9 ) / committee_size ) score . append ( - tmp ) return score