Exemple #1
0
 def getLabels(self, num_instances):
     labels = [None] * num_instances
     families = [None] * num_instances
     gt_labels = [None] * num_instances
     gt_families = [None] * num_instances
     # Labels/Families
     benign_ids = annotations_db_tools.getLabelIds(
         self.experiment.session, self.experiment.experiment_id,
         labels_tools.BENIGN)
     malicious_ids = annotations_db_tools.getLabelIds(
         self.experiment.session, self.experiment.experiment_id,
         labels_tools.MALICIOUS)
     for instance_id in benign_ids + malicious_ids:
         label, family, method = annotations_db_tools.getAnnotationDetails(
             self.experiment.session, self.experiment.experiment_id,
             instance_id)
         labels[self.indexes[
             instance_id]] = labels_tools.labelStringToBoolean(label)
         families[self.indexes[instance_id]] = family
     # True Labels
     has_ground_truth = db_tables.hasGroundTruth(self.experiment)
     if has_ground_truth:
         gt_labels, gt_families = annotations_db_tools.getGroundTruth(
             self.experiment.session, self.experiment.experiment_id)
     return labels, families, gt_labels, gt_families
Exemple #2
0
 def getManualAnnotation(self, iteration):
     details = annotations_db_tools.getAnnotationDetails(
         iteration.experiment.session, iteration.experiment.experiment_id,
         self.instance_id)
     if details is None:
         iteration.conf.logger.warning(
             'Instance %s has not been annotated.' %
             (str(self.instance_id)))
     else:
         label, family, _ = details
         self.updateDatasets(iteration, label, family)
Exemple #3
0
 def checkAnnotationsWithDB(self, experiment):
     for instance_id in self.instances.annotations.getAnnotatedIds():
         label = self.instances.annotations.getLabel(instance_id)
         family = self.instances.annotations.getFamily(instance_id)
         details = annotations_db_tools.getAnnotationDetails(
             experiment.session, experiment.experiment_id, instance_id)
         if details is None:
             # The instance is not annotated anymore
             self.instances.annotations.setLabelFamily(
                 instance_id, None, None)
         else:
             DB_label, DB_family, m = details
             DB_label = labels_tools.labelStringToBoolean(DB_label)
             if DB_label != label or DB_family != family:
                 self.instances.annotations.setLabelFamily(
                     instance_id, DB_label, DB_family)
Exemple #4
0
 def getAnnotations(self):
     labels = [None] * self.num_instances
     families = [None] * self.num_instances
     benign_ids = annotations_db_tools.getLabelIds(
         self.experiment.session, self.experiment.experiment_id,
         labels_tools.BENIGN)
     malicious_ids = annotations_db_tools.getLabelIds(
         self.experiment.session, self.experiment.experiment_id,
         labels_tools.MALICIOUS)
     for instance_id in benign_ids + malicious_ids:
         label, family, method = annotations_db_tools.getAnnotationDetails(
             self.experiment.session, self.experiment.experiment_id,
             instance_id)
         labels[self.indexes[
             instance_id]] = labels_tools.labelStringToBoolean(label)
         families[self.indexes[instance_id]] = family
     return labels, families
Exemple #5
0
 def checkAnswered(self, iteration):
     details = annotations_db_tools.getAnnotationDetails(
         iteration.experiment.session, iteration.experiment.experiment_id,
         self.instance_id)
     return details is not None