// 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