Esempio n. 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
Esempio n. 2
0
 def getGroundTruth(self, ):
     gt_labels = [None] * self.num_instances
     gt_families = [None] * self.num_instances
     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 gt_labels, gt_families
Esempio n. 3
0
def getConf(experiment_id):
    experiment = updateCurrentExperiment(experiment_id)
    conf = experiment.toJson()
    conf['has_ground_truth'] = db_tables.hasGroundTruth(experiment)
    return jsonify(conf)
Esempio n. 4
0
def hasGroundTruth(experiment_id):
    experiment = updateCurrentExperiment(experiment_id)
    return str(db_tables.hasGroundTruth(experiment))
Esempio n. 5
0
 def _checkConf(self):
     if not db_tables.hasGroundTruth(self):
         self.conf.logger.warning(
             'The validation dataset does not have ground-truth.')