def saveInstancesLabels(self, output_filename): with open(output_filename, 'w') as f: print >> f, 'instance_id,label,family' for i in range(self.numInstances()): instance_id = self.ids[i] label = labels_tools.labelBooleanToString(self.labels[i]) family = self.families[i] print >> f, str(instance_id) + ',' + label + ',' + family
def addInstance(self, instance_id, distance, label, family, annotated): self.instances_ids.append(instance_id) self.distances.append(distance) label = labels_tools.labelBooleanToString(label) if family is not None: key = label + '__' + family if key not in self.clusters_families_stats: self.clusters_families_stats[key] = 0 self.clusters_families_stats[key] += 1 if annotated: self.num_annotated_instances += 1
def annotateAuto(self, iteration, kind): instances = iteration.datasets.instances label = instances.getLabel(self.instance_id, true_labels=True) label = labels_tools.labelBooleanToString(label) family = instances.getFamily(self.instance_id, true_labels=True) # Update the datasets self.updateDatasets(iteration, label, family) # Update in the database method = kind + '__annotation' labels_tools.addLabel(iteration.experiment.session, iteration.experiment.labels_id, self.instance_id, label, family, iteration.iteration_number, method, True) iteration.experiment.session.commit()