Skip to content
Snippets Groups Projects
Commit c6783173 authored by Baptiste Bauvin's avatar Baptiste Bauvin
Browse files

Corrected difficulty score

parent 7b3e918b
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ class DiversityFusion(BaseMultiviewClassifier): ...@@ -49,7 +49,7 @@ class DiversityFusion(BaseMultiviewClassifier):
estimator.fit(X.get_v(view_idx, train_indices), y[train_indices]) estimator.fit(X.get_v(view_idx, train_indices), y[train_indices])
self.estimator_pool[classifier_idx].append(estimator) self.estimator_pool[classifier_idx].append(estimator)
else: else:
pass #Todo pass #TODO
self.monoview_estimators = self.choose_combination(X, y, train_indices, views_indices) self.monoview_estimators = self.choose_combination(X, y, train_indices, views_indices)
return self return self
......
...@@ -9,23 +9,21 @@ classifier_class_name = "DifficultyFusion" ...@@ -9,23 +9,21 @@ classifier_class_name = "DifficultyFusion"
class DifficultyFusion(GlobalDiversityFusion): class DifficultyFusion(GlobalDiversityFusion):
def diversity_measure(self, classifiers_decisions, combination, y): def diversity_measure(self, classifiers_decisions, combination, y):
_, nb_view, nb_examples = classifiers_decisions.shape _, nb_view, nb_examples = classifiers_decisions.shape
scores = np.zeros((nb_view, nb_examples), dtype=int) scores = np.zeros((nb_view, nb_examples), dtype=int)
for view_index, classifier_index in enumerate(combination): for view_index, classifier_index in enumerate(combination):
scores[view_index] = np.logical_not( scores[view_index, :] = np.logical_not(
np.logical_xor(classifiers_decisions[classifier_index, np.logical_xor(classifiers_decisions[classifier_index,
view_index], view_index],
y) y)
) )
# difficulty_scores = np.sum(scores, axis=0) # Table of the nuber of views that succeeded for each example :
# TODO : Check computing method difficulty_scores = np.sum(scores, axis=0)
difficulty_score = np.mean(
np.var( difficulty_score = np.var(
np.array([ np.array([
np.sum((scores==view_index), axis=1)/float(nb_view) np.sum((difficulty_scores == view_index))
for view_index in range(len(combination)+1)]) for view_index in range(len(combination)+1)])
, axis=0)
) )
return difficulty_score return difficulty_score
......
...@@ -20,4 +20,4 @@ class Test_difficulty_fusion(unittest.TestCase): ...@@ -20,4 +20,4 @@ class Test_difficulty_fusion(unittest.TestCase):
cls.classifiers_decisions, cls.classifiers_decisions,
cls.combination, cls.combination,
cls.y) cls.y)
cls.assertAlmostEqual(difficulty_measure, 0.22453703703703706) cls.assertAlmostEqual(difficulty_measure, 0.1875)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment