def getClusterPredictedLabel(project, dataset, experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) predicted_label = clustering.getClusterLabel(selected_cluster) return predicted_label
def getClusterLabelsFamilies(project, dataset, experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) labels_families = clustering.getClusterLabelsFamilies(selected_cluster) return jsonify(labels_families)
def removeClusterLabel(experiment_id, selected_cluster, num_results): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) clustering.removeClusterLabel(selected_cluster, num_results) return ''
def getNumElements(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) cluster = clustering.clusters[selected_cluster] res = {} res['num_elements'] = cluster.numInstances() return jsonify(res)
def getClusterLabelFamilyIds(experiment_id, selected_cluster, label, family, num_results): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) ids = clustering.getClusterLabelFamilyIds(selected_cluster, label, family) res = listResultWebFormat(ids, num_results) return jsonify(res)
def getNumElements(project, dataset, experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) cluster = clustering.clusters[selected_cluster] res = {} res['num_elements'] = cluster.numInstances() return jsonify(res)
def getClustersLabels(experiment_id): experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) # Do not consider empty clusters for visualization clusters = [] for c in range(clustering.num_clusters): #if clustering.clusters[c].numInstances() > 0: clusters.append({'id': c, 'label': clustering.clusters[c].label}) return jsonify({'clusters': clusters})
def addClusterLabel(experiment_id, selected_cluster, num_results, label, family, label_iteration, label_method): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) clustering.addClusterLabel(selected_cluster, num_results, label, family, label_iteration, label_method) return ''
def removeClusterLabel(project, dataset, experiment_id, selected_cluster, num_results): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) clustering.removeClusterLabel(selected_cluster, num_results) db.commit() return ''
def getClustersLabels(project, dataset, experiment_id): experiment = ExperimentFactory.getFactory().fromJson( project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) # Do not consider empty clusters for visualization clusters = [] for c in range(clustering.num_clusters): #if clustering.clusters[c].numInstances() > 0: clusters.append({'id': c, 'label': clustering.clusters[c].label}) return jsonify({'clusters': clusters})
def getClusterLabelFamilyIds(project, dataset, experiment_id, selected_cluster, label, family, num_results): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) ids = clustering.getClusterLabelFamilyIds(selected_cluster, label, family) res = web_tools.listResultWebFormat(ids, num_results) return jsonify(res)
def getClusterInstancesVisu(experiment_id, selected_cluster, c_e_r, num_results): num_results = int(num_results) selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) selected_cluster_ids = {} selected_cluster_ids[selected_cluster] = \ clustering.getClusterInstancesVisu( selected_cluster, num_results, random = True)[c_e_r] return jsonify(selected_cluster_ids)
def getClustersLabels(project, dataset, experiment_id): experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) # Do not consider empty clusters for visualization labels = [] for c in range(clustering.num_clusters): if clustering.clusters[c].numInstances() > 0: labels.append('c_' + str(c)) return jsonify({'labels': labels})
def getClusterInstancesVisu(project, dataset, experiment_id, selected_cluster, c_e_r, num_results): num_results = int(num_results) selected_cluster = int(selected_cluster) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) selected_cluster_ids = {} selected_cluster_ids[selected_cluster] = \ clustering.getClusterInstancesVisu( selected_cluster, num_results, random = True)[c_e_r] return jsonify(selected_cluster_ids)
def addClusterLabel(project, dataset, experiment_id, selected_cluster, num_results, label, family, label_iteration, label_method): selected_cluster = int(selected_cluster) num_results = int(num_results) experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) clustering.addClusterLabel(selected_cluster, num_results, label, family, label_iteration, label_method) db.commit() return ''
def getClusterStats(project, dataset, experiment_id): experiment = ExperimentFactory.getFactory().fromJson(project, dataset, experiment_id, db, cursor) clustering = Clustering.fromJson(experiment) num_clusters = clustering.num_clusters num_instances_v = [] labels = [] mysql_tools.useDatabase(cursor, project, dataset) for c in range(num_clusters): instances_in_cluster = clustering.clusters[c].instances_ids num_instances = len(instances_in_cluster) # the empty clusters are not displayed if num_instances > 0: num_instances_v.append(num_instances) labels.append('c_' + str(c)) barplot = BarPlot(labels) barplot.addDataset(num_instances_v, colors_tools.blue, 'Num. Instances') return jsonify(barplot.barplot)
def getClusterStats(experiment_id): experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) num_clusters = clustering.num_clusters num_instances_v = [] labels = [] for c in range(num_clusters): instances_in_cluster = clustering.clusters[c].instances_ids num_instances = len(instances_in_cluster) # the empty clusters are not displayed #if num_instances > 0: num_instances_v.append(num_instances) #labels.append('c_' + str(c)) labels.append(clustering.clusters[c].label) barplot = BarPlot(labels) dataset = PlotDataset(num_instances_v, 'Num. Instances') barplot.addDataset(dataset) return jsonify(barplot.toJson())
def getClusterPredictedLabel(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) predicted_label = clustering.getClusterLabel(selected_cluster) return predicted_label
def getClusterLabelsFamilies(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = Clustering.fromJson(experiment) labels_families = clustering.getClusterLabelsFamilies(selected_cluster) return jsonify(labels_families)