Exemplo n.º 1
0
def WHEREDataTransformation(filename):
    global problem_name, percent_name, repeat_name
    cluster_file_name = "./Cluster_Data/" + str(problem_name) + "_" + str(percent_name) + "_" + str(repeat_name) + ".txt"
    # import pdb
    # pdb.set_trace()

    if os.path.isfile(cluster_file_name) is True:
        print "LOADED FROM THE FILE: ", cluster_file_name
        import pickle
        cluster_table = pickle.load(open(cluster_file_name, "rb"))
        return cluster_table


    from utilities.Tools.methods1 import wrapper_createTbl
    # The Data has to be access using this attribute table._rows.cells
    transformed_table = [[int(z) for z in x.cells[:-1]] + x.cells[-1:] for x in wrapper_createTbl(filename)._rows]
    cluster_numbers = set(map(lambda x: x[-1], transformed_table))

    #debug
    dict = {}
    for line in transformed_table:
        if line[-1] in dict.keys(): dict[line[-1]] += 1
        else: dict[line[-1]] = 1

    # separating clusters
    # the element looks like [clusterno, rows]
    cluster_table = []
    for number in cluster_numbers:
        cluster_table.append([number]+ [filter(lambda x: x[-1] == number, transformed_table)])

    import pickle
    pickle.dump(cluster_table, open(cluster_file_name, "wb"))

    return cluster_table
Exemplo n.º 2
0
def WHEREDataTransformation(filename):
    from utilities.Tools.methods1 import wrapper_createTbl
    # The Data has to be access using this attribute table._rows.cells
    transformed_table = [[int(z) for z in x.cells[:-1]] + x.cells[-1:] for x in wrapper_createTbl(filename)._rows]
    cluster_numbers = set(map(lambda x: x[-1], transformed_table))

    # separating clusters
    # the element looks like [clusterno, rows]
    cluster_table = []
    for number in cluster_numbers:
        cluster_table.append([number] + [filter(lambda x: x[-1] == number, transformed_table)])
    return cluster_table
def where_clusterer(filename):
    """
    This is function accepts a file with rows(=records) and clusters it. This is FASTNAP + PCA
    :param filename: Pass in the filename with rows as valid configurations
    :return: List of Cluster. Each cluster has a [[cluster_number], [list of members]]
    """
    from utilities.Tools.methods1 import wrapper_createTbl
    # The Data has to be access using this attribute table._rows.cells
    transformed_table = [[int(z) for z in x.cells[:-1]] + x.cells[-1:] for x in wrapper_createTbl(filename)._rows]
    cluster_numbers = set(map(lambda x: x[-1], transformed_table))

    # separating clusters
    # the element looks like [clusterno, rows]
    cluster_table = []
    for number in cluster_numbers:
        cluster_table.append([number] + [filter(lambda x: x[-1] == number, transformed_table)])
    return cluster_table
Exemplo n.º 4
0
def where_clusterer(filename):
    """
    This is function accepts a file with rows(=records) and clusters it. This is FASTNAP + PCA
    :param filename: Pass in the filename with rows as valid configurations
    :return: List of Cluster. Each cluster has a [[cluster_number], [list of members]]
    """
    from utilities.Tools.methods1 import wrapper_createTbl
    # The Data has to be access using this attribute table._rows.cells
    transformed_table = [[int(z) for z in x.cells[:-1]] + x.cells[-1:]
                         for x in wrapper_createTbl(filename)._rows]
    cluster_numbers = set(map(lambda x: x[-1], transformed_table))

    # separating clusters
    # the element looks like [clusterno, rows]
    cluster_table = []
    for number in cluster_numbers:
        cluster_table.append(
            [number] + [filter(lambda x: x[-1] == number, transformed_table)])
    return cluster_table
Exemplo n.º 5
0
def WHEREDataTransformation(filename):
    global problem_name, percent_name, repeat_name
    cluster_file_name = "./Cluster_Data/" + str(problem_name) + "_" + str(
        percent_name) + "_" + str(repeat_name) + ".txt"
    # import pdb
    # pdb.set_trace()

    if os.path.isfile(cluster_file_name) is True:
        print "LOADED FROM THE FILE: ", cluster_file_name
        import pickle
        cluster_table = pickle.load(open(cluster_file_name, "rb"))
        return cluster_table

    from utilities.Tools.methods1 import wrapper_createTbl
    # The Data has to be access using this attribute table._rows.cells
    transformed_table = [[int(z) for z in x.cells[:-1]] + x.cells[-1:]
                         for x in wrapper_createTbl(filename)._rows]
    cluster_numbers = set(map(lambda x: x[-1], transformed_table))

    #debug
    dict = {}
    for line in transformed_table:
        if line[-1] in dict.keys(): dict[line[-1]] += 1
        else: dict[line[-1]] = 1

    # separating clusters
    # the element looks like [clusterno, rows]
    cluster_table = []
    for number in cluster_numbers:
        cluster_table.append(
            [number] + [filter(lambda x: x[-1] == number, transformed_table)])

    import pickle
    pickle.dump(cluster_table, open(cluster_file_name, "wb"))

    return cluster_table