コード例 #1
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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
コード例 #2
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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)
コード例 #3
0
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 ''
コード例 #4
0
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)
コード例 #5
0
ファイル: clusterings.py プロジェクト: william-vu/SecuML
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)
コード例 #6
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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)
コード例 #7
0
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})
コード例 #8
0
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 ''
コード例 #9
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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 ''
コード例 #10
0
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})
コード例 #11
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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)
コード例 #12
0
ファイル: clusterings.py プロジェクト: william-vu/SecuML
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)
コード例 #13
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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})
コード例 #14
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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)
コード例 #15
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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 ''
コード例 #16
0
ファイル: clusterings.py プロジェクト: r3dlight/SecuML
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)
コード例 #17
0
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())
コード例 #18
0
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
コード例 #19
0
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)