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