示例#1
0
def getNumElements(exp_id, selected_cluster):
    selected_cluster = int(selected_cluster)
    experiment = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(experiment.output_dir())
    cluster = clustering.clusters[selected_cluster]
    res = {}
    res['num_elements'] = cluster.num_instances()
    return jsonify(res)
示例#2
0
def getClusterLabelFamilyIds(exp_id, cluster_id, label, family, num_results):
    cluster_id = int(cluster_id)
    num_results = int(num_results)
    exp = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(exp.output_dir())
    ids = clustering.get_labe_family_ids(exp, cluster_id, label, family)
    return jsonify({'num_ids': len(ids),
                    'ids': _random_selection(ids, num_results)})
示例#3
0
def getClustersLabels(exp_id):
    experiment = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(experiment.output_dir())
    # Do not consider empty clusters for visualization
    clusters = []
    for c in range(clustering.num_clusters):
        # if clustering.clusters[c].num_instances() > 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 = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(exp.output_dir())
    ids = {}
    ids[selected_cluster] = clustering.get_cluster_instances_visu(
        selected_cluster, num_results, random=True)[c_e_r]
    return jsonify(ids)
示例#5
0
def getClusterStats(exp_id):
    experiment = update_curr_exp(exp_id)
    clustering = ClustersExp.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)
        num_instances_v.append(num_instances)
        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())
示例#6
0
def getClusterLabelsFamilies(exp_id, cluster_id):
    cluster_id = int(cluster_id)
    experiment = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(experiment.output_dir())
    return jsonify(clustering.get_labels_families(experiment, cluster_id))
示例#7
0
def getClusterLabel(exp_id, selected_cluster):
    selected_cluster = int(selected_cluster)
    experiment = update_curr_exp(exp_id)
    clustering = ClustersExp.from_json(experiment.output_dir())
    predicted_label = clustering.get_label(selected_cluster)
    return predicted_label