Ejemplo n.º 1
0
def test_trim_learner():
    if len(sys.argv) == 2 and sys.argv[1] in ['label-flipping', 'k-insertion',
                                              'data-modification', 'dummy']:
        attacker_name = sys.argv[1]
    else:
        attacker_name = 'dummy'

    # Data processing unit
    # The path is an index of 400 testing samples(raw email data).
    dataset = EmailDataset(path='./data_reader/data/raw/trec05p-1/test-400',
                           binary=False, raw=True)

    tester = TestDataPoisoningLearner('trim', attacker_name, dataset)
    result = tester.test()
    report(result)
Ejemplo n.º 2
0
def test_dp_learners():
    if len(sys.argv) == 2 and sys.argv[1] in [
            'label-flipping', 'k-insertion', 'data-modification', 'dummy'
    ]:
        attacker_name = sys.argv[1]
    else:
        attacker_name = 'dummy'

    # Data processing unit
    # The path is an index of 400 testing samples(raw email data).
    dataset = EmailDataset(path='./data_reader/data/raw/trec05p-1/test-400',
                           binary=False,
                           raw=True)

    learners = ['trim', 'atrim', 'irl', 'outlier-removal']
    tester = TestDataPoisoningLearner(learners, attacker_name, dataset)
    results = tester.test()

    for i, tup in enumerate(results):
        report(tup, learners[i].upper())