Example #1
0
 def setUp(self):
     features = np.array([ [0, 1], [1, 2] ], dtype=int)
     bins = [
        [1, 2, 3, 4],
        [0, 0, 1, 1],
        [34, 33, 13, 134],
        [52, 42, 57, 21]
     ]
     thresholds = [ 10, 5]
     self.fern1 = Fern(2, features, np.array(bins), np.array(thresholds))
Example #2
0
class FernTest(unittest.TestCase):
    def setUp(self):
        features = np.array([[0, 1], [1, 2]], dtype=int)
        bins = [[1, 2, 3, 4], [0, 0, 1, 1], [34, 33, 13, 134],
                [52, 42, 57, 21]]
        thresholds = [10, 5]
        self.fern1 = Fern(2, features, np.array(bins), np.array(thresholds))

    def test_apply(self):
        test_cases = [{
            "pixels": [100, 14, 123],
            "result": [[34, 33], [13, 134]]
        }]

        for t in test_cases:
            ans = self.fern1.apply(np.array(t['pixels']))
            compare_arrays(self, ans, np.array(t['result']))
Example #3
0
class FernTest(unittest.TestCase):
    def setUp(self):
        features = np.array([ [0, 1], [1, 2] ], dtype=int)
        bins = [
           [1, 2, 3, 4],
           [0, 0, 1, 1],
           [34, 33, 13, 134],
           [52, 42, 57, 21]
        ]
        thresholds = [ 10, 5]
        self.fern1 = Fern(2, features, np.array(bins), np.array(thresholds))

    def test_apply(self):
        test_cases = [
            {
                "pixels": [100, 14, 123],
                "result": [[34, 33], [13, 134]]
            }
        ]

        for t in test_cases:
            ans = self.fern1.apply(np.array(t['pixels']))
            compare_arrays(self, ans, np.array(t['result']))
Example #4
0
 def setUp(self):
     features = np.array([[0, 1], [1, 2]], dtype=int)
     bins = [[1, 2, 3, 4], [0, 0, 1, 1], [34, 33, 13, 134],
             [52, 42, 57, 21]]
     thresholds = [10, 5]
     self.fern1 = Fern(2, features, np.array(bins), np.array(thresholds))