Ejemplo n.º 1
0
 def get_item_labels(item):
     if add_parents:
         all_labels = set(item['labels'])
         for label in item['labels']:
             for l2 in disease_label_table.get_inferred_labels(label):
                 all_labels.add(l2)
         return list(all_labels)
     else:
         return item['labels']
Ejemplo n.º 2
0
 def get_item_labels(item):
     if add_parents:
         all_labels = set(item['labels'])
         for label in item['labels']:
             for l2 in disease_label_table.get_inferred_labels(label):
                 all_labels.add(l2)
         return list(all_labels)
     else:
         return item['labels']
def best_guess(classifier, X):
    probs = classifier.predict_proba(X)[0]
    p_max = max(probs)
    result = {}
    for i,p in enumerate(probs):
        cutoff_ratio = 0.65
        parents = disease_label_table.get_inferred_labels(classifier.classes_[i])
        if p >= p_max * cutoff_ratio:
            result[i] = max(p, result.get(i, 0))
            for i2, label in enumerate(classifier.classes_):
                if label in parents:
                    result[i2] = max(p, probs[i2], result.get(i2, 0))
    return result.items()
Ejemplo n.º 4
0
 def best_guess(self, X):
     probs = self.classifier.predict_proba(X)[0]
     p_max = max(probs)
     result = {}
     for i, p in enumerate(probs):
         cutoff_ratio = self.cutoff_ratio
         parents = disease_label_table.get_inferred_labels(
             self.classifier.classes_[i])
         if p >= p_max * self.cutoff_ratio:
             result[i] = max(p, result.get(i, 0))
             for i2, label in enumerate(self.classifier.classes_):
                 if label in parents:
                     result[i2] = max(p, probs[i2], result.get(i2, 0))
     return result.items()
Ejemplo n.º 5
0
 def test_inference(self):
     import disease_label_table
     self.assertSetEqual(set(['Avian Influenza', 'Influenza']),
         set(disease_label_table.get_inferred_labels('Avian Influenza H7N9')))