예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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})
예제 #4
0
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)
예제 #5
0
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))
예제 #6
0
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())
예제 #7
0
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