Exemple #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.RahulTool.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
Exemple #2
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.RahulTool.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
Exemple #3
0
def WHEREDataTransformation(filename):
    from utilities.RahulTool.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
Exemple #4
0
def WHEREDataTransformation(filename):
    from utilities.RahulTool.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