873a906cb76f0c6988d6547078103b67b73a7262,deslib/des/des_knn.py,DESKNN,estimate_competence,#DESKNN#Any#Any#,101

Before Change


                    The diversity estimated for each base classifier
        
        _, idx_neighbors = self._get_region_competence(query)
        idx_neighbors = idx_neighbors.reshape(1, -1)
        hit_result = self.processed_dsel[idx_neighbors, :]
        predicted_matrix = self.BKS_dsel[idx_neighbors, :]
        // calculate the classifiers mean accuracy for all samples
        competences = np.mean(hit_result, axis=1)

After Change


        
        _, idx_neighbors = self._get_region_competence(query)
        // calculate the classifiers mean accuracy for all samples/base classifier
        accuracy = np.mean(self.processed_dsel[idx_neighbors, :], axis=1)

        predicted_matrix = self.BKS_dsel[idx_neighbors, :]
        targets = self.DSEL_target[idx_neighbors]

        // TODO: try to optimize this part with numpy instead of for
        // Calculate the more_diverse matrix. It becomes computationally expensive
        // When the region of competence is high
        diversity = np.zeros((query.shape[0], self.n_classifiers))
        for sample_idx in range(query.shape[0]):
            for clf_index in range(self.n_classifiers):
                for clf_index2 in range(clf_index + 1, self.n_classifiers):
                    this_diversity = self.diversity_func(targets[sample_idx, :],
                                                         predicted_matrix[sample_idx, :, clf_index],
                                                         predicted_matrix[sample_idx, :, clf_index2])
                    diversity[sample_idx, clf_index] += this_diversity
                    diversity[sample_idx, clf_index2] += this_diversity

        competences = {"accuracy" : accuracy, "diversity" : diversity}

        return competences

    def select(self, competences):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: scikit-learn-contrib/DESlib
Commit Name: 873a906cb76f0c6988d6547078103b67b73a7262
Time: 2018-04-02
Author: rafaelmenelau@gmail.com
File Name: deslib/des/des_knn.py
Class Name: DESKNN
Method Name: estimate_competence


Project Name: pyannote/pyannote-audio
Commit Name: b0a78567606a3ff24437501fc83239181b9478b3
Time: 2019-02-28
Author: pavel.korshunov@idiap.ch
File Name: pyannote/audio/features/utils.py
Class Name: RawAudio
Method Name: __call__


Project Name: tensorflow/models
Commit Name: 8da4857396fcedb1abd19a08cd4de40d16c7bc50
Time: 2020-08-17
Author: 30733558+plakal@users.noreply.github.com
File Name: research/audioset/yamnet/yamnet_test.py
Class Name: YAMNetTest
Method Name: clip_test