Exemplo n.º 1
0
    def test_save_and_load(self):
        try:
            self.oll = oll.oll('PA1')
            self.oll.add({1: 1.0}, 1)
            filename = tempfile.mkstemp()[1]
            self.oll.save(filename)
            ok_(os.path.exists(filename))

            self.oll = oll.oll('PA1')
            self.oll.load(filename)
            assert_almost_equals(self.oll.classify({0: 1.0, 1: 1.0}), 0.5, 6)
        finally:
            os.remove(filename)
Exemplo n.º 2
0
    def test_testFile(self):
        try:
            self.oll = oll.oll('PA1')
            self.oll.add({0: 1.0, 1: 1.0}, 1)
            self.oll.add({2: -1.0, 3: -1.0}, -1)
            model_filename = tempfile.mkstemp()[1]
            self.oll.save(model_filename)

            test_filename = tempfile.mkstemp()[1]
            with open(test_filename, 'w') as fd:
                fd.write('+1 0:1.0 1:1.0\n')
                fd.write('-1 2:-1.0 3:-1.0\n')

            actual = self.oll.testFile(test_filename, 0)
            desired = {
                'accuracy': 100.0,
                'true-positive': 1,
                'false-positive': 0,
                'true-negative': 1,
                'false-negative': 0
            }
            eq_(actual, desired)
        finally:
            os.remove(model_filename)
            os.remove(test_filename)
Exemplo n.º 3
0
 def __init__(self):
     self.oll = oll.oll('PA1')
Exemplo n.º 4
0
 def test__init__(self):
     for method in ('P', 'AP', 'PA', 'PA1', 'PA2', 'PAK', 'CW', 'AL'):
         ok_(oll.oll(method))
Exemplo n.º 5
0
 def __init__(self):
     self.oll = oll.oll('PA1')