def source_competence(self): """The source of competence C_src at the validation point :math:`\mathbf{x}_{k}` is calculated by logarithm function in the support obtained by the base classifier. Returns ---------- C_src : array of shape = [n_samples, n_classifiers] The competence source for each base classifier at each data point. """ C_src = np.zeros((self.n_samples, self.n_classifiers)) for clf_index in range(self.n_classifiers): supports = self.dsel_scores[:, clf_index, :] support_correct = supports[np.arange(self.n_samples), self.DSEL_target] C_src[:, clf_index] = log_func(self.n_classes, support_correct) return C_src
def source_competence(self): """The source of competence C_src at the validation point xk is calculated by logarithm in the support obtained by the base classifier. Returns ---------- C_src : array of shape = [n_samples, n_classifiers] The competence source for each base classifier at each data point. """ C_src = np.zeros((self.n_samples, self.n_classifiers)) for clf_index in range(self.n_classifiers): supports = self._get_scores_dsel(clf_index) support_correct = [ supports[sample_idx, i] for sample_idx, i in enumerate(self.DSEL_target) ] support_correct = np.array(support_correct) C_src[:, clf_index] = log_func(self.n_classes, support_correct) return C_src
def test_log_func_multi_class(supports_correct, expected): n_classes = 3 result = log_func(n_classes, supports_correct) assert np.isclose(result, expected, atol=0.01)
def test_log_func_two_classes(supports_correct, expected): n_classes = 2 result = log_func(n_classes, supports_correct) assert np.isclose(result, expected)