def getClusterLabelsFamilies(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = ClusteringExp.from_json(experiment.output_dir()) labels_families = clustering.getClusterLabelsFamilies( experiment, selected_cluster) return jsonify(labels_families)
def getNumElements(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = ClusteringExp.from_json(experiment.output_dir()) cluster = clustering.clusters[selected_cluster] res = {} res['num_elements'] = cluster.numInstances() return jsonify(res)
def getClustersLabels(experiment_id): experiment = updateCurrentExperiment(experiment_id) clustering = ClusteringExp.from_json(experiment.output_dir()) # 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 getClusterInstancesVisu(exp_id, selected_cluster, c_e_r, num_results): num_results = int(num_results) selected_cluster = int(selected_cluster) exp = updateCurrentExperiment(exp_id) clustering = ClusteringExp.from_json(exp.output_dir()) ids = {} ids[selected_cluster] = clustering.getClusterInstancesVisu( selected_cluster, num_results, random=True)[c_e_r] return jsonify(ids)
def getClusterLabelFamilyIds(exp_id, selected_cluster, label, family, num_results): selected_cluster = int(selected_cluster) num_results = int(num_results) exp = updateCurrentExperiment(exp_id) clustering = ClusteringExp.from_json(exp.output_dir()) ids = clustering.getClusterLabelFamilyIds(exp, selected_cluster, label, family) return jsonify(listResultWebFormat(ids, num_results))
def getClusterStats(experiment_id): experiment = updateCurrentExperiment(experiment_id) clustering = ClusteringExp.from_json(experiment.output_dir()) 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.add_dataset(dataset) return jsonify(barplot.to_json())
def getClusterPredictedLabel(experiment_id, selected_cluster): selected_cluster = int(selected_cluster) experiment = updateCurrentExperiment(experiment_id) clustering = ClusteringExp.from_json(experiment.output_dir()) predicted_label = clustering.getClusterLabel(selected_cluster) return predicted_label