예제 #1
0
def get_result_K(att_trees, data, L=5):
    "change K, while fixing L"
    data_back = copy.deepcopy(data)
    for K in range(5, 55, 5):
        result = APA(att_trees[-1], data, K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data, result, K, L))
예제 #2
0
def get_result_L(att_trees, data, K=10):
    "change L, while fixing K"
    data_back = copy.deepcopy(data)
    for L in range(5, 55, 5):
        result = APA(att_trees[-1], data, K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data, result, K, L))
예제 #3
0
파일: anonymizer.py 프로젝트: zshwuhan/PAA
def get_result_K(att_trees, data, L=5):
    "change K, while fixing L"
    data_back = copy.deepcopy(data)
    for K in range(5, 55, 5):
        result = PAA(att_trees[-1], data, K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data, result, K, L))
예제 #4
0
파일: anonymizer.py 프로젝트: zshwuhan/PAA
def get_result_L(att_trees, data, K=10):
    "change L, while fixing K"
    data_back = copy.deepcopy(data)
    for L in range(5, 55, 5):
        result = PAA(att_trees[-1], data, K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data, result, K, L))
def get_result_m(att_tree, data, type_alg, k=DEFALUT_K, threshold=DEFALUT_T):
    """
    change k, whle fixing size of dataset
    """
    print "K=%d" % k
    print "Threshold=%.2f" % threshold
    print "Size of Data", len(data)
    data_back = copy.deepcopy(data)
    # for m in range(1, 100, 5):
    all_rncp = []
    all_tncp = []
    all_rtime = []
    for m in [1, 2, 3, 4, 5, M_MAX]:
        print '#' * 30
        print "m=%d" % m
        result, eval_result = rt_anon(att_tree, data, type_alg, k, m, threshold)
        save_to_file((att_tree, data, result, k, m))
        data = copy.deepcopy(data_back)
        print "RNCP %0.2f" % eval_result[0] + "%"
        all_rncp.append(round(eval_result[0], 2))
        print "TNCP %0.2f" % eval_result[1] + "%"
        all_tncp.append(round(eval_result[1], 2))
        print "Running time %0.2f" % eval_result[2] + " seconds"
        all_rtime.append(round(eval_result[2], 2))
    print "RNCP", all_rncp
    print "TNCP", all_tncp
    print "Running time", all_rtime
def get_result_k(att_tree, data, type_alg, m=DEFALUT_M, threshold=DEFALUT_T):
    """
    change k, whle fixing size of dataset
    """
    data_back = copy.deepcopy(data)
    # for k in range(5, 105, 5):
    print "m=%d" % m
    print "Threshold=%.2f" % threshold
    print "Size of Data", len(data)
    all_rncp = []
    all_tncp = []
    all_rtime = []
    # for k in range(5, 55, 5):
    #     if k in [2, 5, 10, 25, 50, 100]:
    #         continue
    for k in [2, 5, 10, 25, 50, 100]:
        print '#' * 30
        print "K=%d" % k
        result, eval_result = rt_anon(att_tree, data, type_alg, k, m, threshold)
        save_to_file((att_tree, data, result, k, m))
        data = copy.deepcopy(data_back)
        print "RNCP %0.2f" % eval_result[0] + "%"
        all_rncp.append(round(eval_result[0], 2))
        print "TNCP %0.2f" % eval_result[1] + "%"
        all_tncp.append(round(eval_result[1], 2))
        print "Running time %0.2f" % eval_result[2] + " seconds"
        all_rtime.append(round(eval_result[2], 2))
    print "RNCP", all_rncp
    print "TNCP", all_tncp
    print "Running time", all_rtime
def get_result_one(att_tree, data, type_alg, k=DEFALUT_K, m=DEFALUT_M, threshold=DEFALUT_T):
    """
    run RT_ANON for one time, with k=10
    """
    print "K=%d" % k
    print "Size of Data", len(data)
    print "m=%d" % m
    print "Threshold=%.2f" % threshold
    result, eval_result = rt_anon(att_tree, data, type_alg, k, m, threshold)
    save_to_file((att_tree, data, result, k, m))
    print "RNCP %0.2f" % eval_result[0] + "%"
    print "TNCP %0.2f" % eval_result[1] + "%"
    print "Running time %0.2f" % eval_result[2] + " seconds"
예제 #8
0
def get_result_dataset(att_trees, data, K=10, L=5):
    "fix k and l, while changign dataset size"
    data_back = copy.deepcopy(data)
    length = len(data_back)
    joint = 5000
    h = length / joint
    if length % joint == 0:
        h += 1
    for i in range(1, h + 1):
        pos = i * joint
        if pos > length:
            continue
        result = APA(att_trees[-1], data[0:pos], K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data[0:pos], result, K, L))
예제 #9
0
파일: anonymizer.py 프로젝트: zshwuhan/PAA
def get_result_dataset(att_trees, data, K=10, L=5):
    "fix k and l, while changign dataset size"
    data_back = copy.deepcopy(data)
    length = len(data_back)
    joint = 5000
    h = length / joint
    if length % joint == 0:
        h += 1
    for i in range(1, h+1):
        pos = i * joint
        if pos > length:
            continue
        result = PAA(att_trees[-1], data[0:pos], K, L)
        data = copy.deepcopy(data_back)
        save_to_file((att_trees, data[0:pos], result, K, L))
def get_result_dataset(att_tree, data, type_alg='RMR',
                       k=DEFALUT_K, m=DEFALUT_M, threshold=DEFALUT_T, num_test=10):
    """
    fix k, while changing size of dataset
    num_test is the test nubmber.
    """
    print "K=%d" % k
    print "m=%d" % m
    print "Threshold=%.2f" % threshold
    data_back = copy.deepcopy(data)
    length = len(data_back)
    joint = 5000
    dataset_num = length / joint
    if length % joint == 0:
        dataset_num += 1
    for i in range(1, dataset_num + 1):
        pos = i * joint
        rncp = tncp = rtime = 0
        if pos > length:
            continue
        print '#' * 30
        print "size of dataset %d" % pos
        for j in range(num_test):
            temp = random.sample(data, pos)
            result, eval_result = rt_anon(att_tree, temp, type_alg, k, m, threshold)
            save_to_file((att_tree, temp, result, k, m), number=j)
            rncp += eval_result[0]
            tncp += eval_result[1]
            rtime += eval_result[2]
            data = copy.deepcopy(data_back)
        rncp /= num_test
        tncp /= num_test
        rtime /= num_test
        print "RNCP %0.2f" % rncp + "%"
        all_rncp.append(round(rncp, 2))
        print "TNCP %0.2f" % tncp + "%"
        all_tncp.append(round(tncp, 2))
        print "Running time %0.2f" % rtime + " seconds"
        all_rtime.append(round(rtime, 2))
    print "RNCP", all_rncp
    print "TNCP", all_tncp
    print "Running time", all_rtime
예제 #11
0
def get_result_one(att_trees, data, K=10, L=5):
    "fix K=10, L=5"
    data_back = copy.deepcopy(data)
    result = APA(att_trees[-1], data, K, L)
    data = copy.deepcopy(data_back)
    save_to_file((att_trees, data, result, K, L))
예제 #12
0
파일: anonymizer.py 프로젝트: zshwuhan/PAA
def get_result_one(att_trees, data, K=10, L=5):
    "fix K=10, L=5"
    data_back = copy.deepcopy(data)
    result = PAA(att_trees[-1], data, K, L)
    data = copy.deepcopy(data_back)
    save_to_file((att_trees, data, result, K, L))