def checkInputParams(self, experiment): if self.auto: # Check true labels are available for the oracle if not db_tables.hasTrueLabels(experiment): raise InvalidInputArguments( 'true_labels.csv must be provided to run Active Learning with an oracle.' )
def getLabels(self, num_instances): labels = [None] * num_instances families = [None] * num_instances annotations = [False] * num_instances true_labels = [None] * num_instances true_families = [None] * num_instances ## Labels/Families benign_ids = labels_tools.getLabelIds(self.experiment, 'benign') malicious_ids = labels_tools.getLabelIds(self.experiment, 'malicious') for instance_id in benign_ids + malicious_ids: label, family, method, annotation = labels_tools.getLabelDetails( self.experiment, instance_id) labels[self.indexes[instance_id]] = label == 'malicious' families[self.indexes[instance_id]] = family annotations[self.indexes[instance_id]] = annotation ## True Labels has_true_labels = db_tables.hasTrueLabels(self.experiment) if has_true_labels: true_labels, true_families = labels_tools.getTrueLabelsFamilies( self.experiment) return labels, families, annotations, true_labels, true_families
def getConf(experiment_id): experiment = updateCurrentExperiment(experiment_id) conf = experiment.toJson() conf['has_true_labels'] = db_tables.hasTrueLabels(experiment) return jsonify(conf)
def getTrueLabelsExperiment(experiment_id): experiment = updateCurrentExperiment(experiment_id) true_labels_exp_id = db_tables.hasTrueLabels(experiment) return str(true_labels_exp_id)