f0c15f219b0761b14329ddd416cda82fa4bae841,deslib/dcs/mcb.py,MCB,estimate_competence,#MCB#Any#Any#,98

Before Change


        BKS_query = predictions

        // Use the BKS to filter the competence region
        selected_idx = []
        for sample_index in idx_neighbors:
            T = (self.BKS_dsel[sample_index][:] == BKS_query)
            S = sum(T) / self.n_classifiers
            if S > self.similarity_threshold:
                selected_idx.append(sample_index)

        // Use the whole neighborhood if no sample is selected to form the region of competence
        if len(selected_idx) == 0:
            selected_idx = idx_neighbors
        // Estimate the classifier competence for the filtered region of competence
        for clf_index in range(self.n_classifiers):

            // Check if the dynamic frienemy pruning (DFP) should be used used
            if self.DFP_mask[clf_index]:
                clf_competence = [self.processed_dsel[sample_idx][clf_index] for sample_idx in selected_idx]
                competences[clf_index] = np.mean(np.array(clf_competence))

        return competences

After Change


        

        _, idx_neighbors = self._get_region_competence(query)
        idx_neighbors = np.atleast_2d(idx_neighbors)

        // Use the pre-compute decisions to transform the query to the BKS space
        BKS_query = predictions

        T = (self.BKS_dsel[idx_neighbors] == BKS_query.reshape(BKS_query.shape[0], -1, BKS_query.shape[1]))
        S = np.sum(T, axis=2) / self.n_classifiers

        // get a mask with the neighbors that will be considered for the competence estimation for all samples.
        boolean_mask = (S > self.similarity_threshold)
        boolean_mask[~np.any(boolean_mask, axis=1), :] = True
        // Expanding this mask to the third axis (n_classifiers) since it is the same for each classifier.
        boolean_mask = np.repeat(np.expand_dims(boolean_mask, axis=2), self.n_classifiers, axis=2)

        // Use the masked array mean to take into account the removed neighbors
        processed_pred = np.ma.MaskedArray(self.processed_dsel[idx_neighbors, :], mask=~boolean_mask)
        competences = np.ma.mean(processed_pred, axis=1)

        return competences
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: scikit-learn-contrib/DESlib
Commit Name: f0c15f219b0761b14329ddd416cda82fa4bae841
Time: 2018-03-28
Author: rafaelmenelau@gmail.com
File Name: deslib/dcs/mcb.py
Class Name: MCB
Method Name: estimate_competence


Project Name: scikit-learn-contrib/DESlib
Commit Name: 44bdf9be3b913a1a0e90115e45edbee192d01b90
Time: 2018-03-31
Author: rafaelmenelau@gmail.com
File Name: deslib/des/probabilistic.py
Class Name: Probabilistic
Method Name: estimate_competence


Project Name: scikit-learn-contrib/DESlib
Commit Name: 0e17f47e9a4920e276bb61b60d6de16264bc6bcf
Time: 2017-12-29
Author: rafaelmenelau@gmail.com
File Name: pythonds/util/aggregation.py
Class Name:
Method Name: majority_voting