コード例 #1
0
 def test_select_best_attribute_with_gini_denominator_zero(self):
     samples = ObliviousDataset.create(
         Sample([s(0), s(0), s(1), s(0)], s(1)),
         Sample([s(0), s(0), s(1), s(0)], s(1)),
         Sample([s(0), s(0), s(0), s(0)], s(0)))
     (best_attribute, _) = select_best_attribute(samples)
     self.assertEqual(reveal(best_attribute), 2)
コード例 #2
0
 def test_column_with_secret_index(self):
     dataset = ObliviousDataset.create(sample(s(0), s(1), s(2)),
                                       sample(s(10), s(11), s(12)),
                                       sample(s(20), s(21), s(22)))
     self.assertEqual(reveal(dataset.column(s(0))), [0, 10, 20])
     self.assertEqual(reveal(dataset.column(s(1))), [1, 11, 21])
     self.assertEqual(reveal(dataset.column(s(2))), [2, 12, 22])
コード例 #3
0
 def test_random_sample(self):
     dataset = ObliviousDataset.create(
         Sample([s(1), s(2), s(3)], s(4)),
         Sample([s(11), s(12), s(13)], s(14)))
     randomSamples = [reveal(dataset.choice()) for _ in range(100)]
     self.assertIn(Sample([1, 2, 3], 4), randomSamples)
     self.assertIn(Sample([11, 12, 13], 14), randomSamples)
コード例 #4
0
 def test_outcomes(self):
     dataset = ObliviousDataset.create(
         Sample([s(0), s(1), s(2)], outcome=s(60)),
         Sample([s(10), s(11), s(12)], outcome=s(70)),
         Sample([s(20), s(21), s(22)],
                outcome=s(80))).select([s(1), s(0), s(1)])
     self.assertEqual(reveal(dataset.outcomes), [60, 80])
コード例 #5
0
 def test_continuous_attributes(self):
     dataset = ObliviousDataset.create(Sample([s(0), s(1), s(1)], s(0)),
                                       Sample([s(1), s(2), s(1)], s(1)),
                                       continuous=[False, True, False])
     self.assertFalse(dataset.is_continuous(0))
     self.assertTrue(dataset.is_continuous(1))
     self.assertFalse(dataset.is_continuous(2))
コード例 #6
0
 def test_continuous_attribute_check_with_secret_index(self):
     dataset = ObliviousDataset.create(Sample([s(0), s(1), s(1)], s(0)),
                                       Sample([s(1), s(2), s(1)], s(1)),
                                       continuous=[False, True, False])
     self.assertFalse(reveal(dataset.is_continuous(s(0))))
     self.assertTrue(reveal(dataset.is_continuous(s(1))))
     self.assertFalse(reveal(dataset.is_continuous(s(2))))
コード例 #7
0
 def test_select_best_attribute(self):
     samples = ObliviousDataset.create(
         Sample([s(0), s(1), s(1), s(0)], s(1)),
         Sample([s(1), s(0), s(1), s(1)], s(1)),
         Sample([s(0), s(0), s(0), s(1)], s(0)))
     (best_attribute, threshold) = select_best_attribute(samples)
     self.assertEqual(reveal(best_attribute), 2)
     self.assertEqual(reveal(threshold), 0)
コード例 #8
0
 async def test_single_sample_with_some_depth(self):
     samples = ObliviousDataset.create(Sample([s(1)], s(1)))
     self.assertEqual(
         reveal(await train(samples, depth=2)),
         Branch(0,
                threshold=0,
                left=Branch(0, threshold=0, left=pruned(), right=pruned()),
                right=Branch(0, threshold=0, left=pruned(), right=leaf(1))))
コード例 #9
0
 def test_select_best_attribute_using_subset(self):
     samples = ObliviousDataset.create(
         Sample([s(0), s(1), s(1), s(0)], s(1)),
         Sample([s(1), s(0), s(1), s(1)], s(1)),
         Sample([s(42), s(43), s(44), s(45)], s(46)),
         Sample([s(0), s(0), s(0), s(1)], s(0)),
     ).select([s(0), s(1), s(0), s(1)])
     (best_attribute, _) = select_best_attribute(samples)
     self.assertEqual(reveal(best_attribute), 2)
コード例 #10
0
 def test_partition_on_binary_attribute(self):
     data = ObliviousDataset.create(sample(s(0), s(1), s(1), s(0)),
                                    sample(s(1), s(0), s(1), s(1)),
                                    sample(s(0), s(0), s(0), s(1)))
     left, right = partition_binary(data, attribute_index=s(2))
     self.assertEqual(reveal(left), [Sample([0, 0, 0, 1], 0)])
     self.assertEqual(reveal(right),
                      [Sample([0, 1, 1, 0], 0),
                       Sample([1, 0, 1, 1], 0)])
コード例 #11
0
 def test_select_best_attribute_from_continuous_and_binary(self):
     samples = ObliviousDataset.create(Sample([s(0), s(1)], s(0)),
                                       Sample([s(0), s(2)], s(0)),
                                       Sample([s(1), s(3)], s(0)),
                                       Sample([s(1), s(4)], s(1)),
                                       Sample([s(1), s(5)], s(1)),
                                       continuous=[False, True])
     (best_attribute, threshold) = select_best_attribute(samples)
     self.assertEqual(reveal(best_attribute), 1)
     self.assertEqual(reveal(threshold), 3)
コード例 #12
0
 def test_calculate_gains_for_thresholds_ignores_duplicates(self):
     samples = ObliviousDataset.create(Sample([s(0)], s(0)),
                                       Sample([s(0)], s(0)),
                                       Sample([s(0)], s(0)),
                                       continuous=[True])
     column = samples.column(0)
     outcomes = samples.outcomes
     gains = calculate_gains_for_thresholds(column, outcomes)
     plain_gains = reveal(gains)
     self.assertEqual(len(plain_gains), 1)
コード例 #13
0
 def test_partition_on_continuous_attribute(self):
     data = ObliviousDataset.create(sample(s(1), s(3), s(3), s(1)),
                                    sample(s(3), s(1), s(3), s(3)),
                                    sample(s(1), s(1), s(1), s(3)))
     left, right = partition_continuous(data,
                                        attribute_index=s(2),
                                        threshold=s(2))
     self.assertEqual(reveal(left), [Sample([1, 1, 1, 3], 0)])
     self.assertEqual(reveal(right),
                      [Sample([1, 3, 3, 1], 0),
                       Sample([3, 1, 3, 3], 0)])
コード例 #14
0
 def test_sorts_column_and_outcomes_of_array(self):
     dataset = ObliviousDataset.create(
         Sample([s(2)], s(5)),
         Sample([s(1)], s(6)),
         Sample([s(3)], s(7)),
         Sample([s(4)], s(8))
     )
     column = dataset.column(s(0))
     outcomes = dataset.outcomes
     sorted_column, sorted_outcomes = sort(column, outcomes)
     self.assertEqual(reveal(sorted_column), [1, 2, 3, 4])
     self.assertEqual(reveal(sorted_outcomes), [6, 5, 7, 8])
コード例 #15
0
async def random_attributes(samples, amount):
    columns, continuous, labels = await random_columns(samples, amount)
    outcomes = samples.outcomes
    smaller_samples = []
    for r in range(len(samples)):
        inputs = []
        outcome = outcomes[r]
        for c in range(len(columns)):
            inputs.append(columns[c][r])
        smaller_samples.append(Sample(inputs, outcome))
    return ObliviousDataset.create(*smaller_samples,
                                   continuous=continuous,
                                   labels=labels)
コード例 #16
0
 async def test_continuous_attribute_with_some_depth(self):
     samples = ObliviousDataset.create(Sample([s(1)], s(0)),
                                       Sample([s(2)], s(0)),
                                       Sample([s(3)], s(1)),
                                       Sample([s(4)], s(1)),
                                       Sample([s(5)], s(0)),
                                       continuous=[True])
     tree = reveal(await train(samples, depth=2))
     self.assertEqual(tree.attribute, 0)
     self.assertEqual(tree.threshold, 2)
     self.assertTrue(isinstance(tree.left, Branch))
     self.assertTrue(isinstance(tree.right, Branch))
     self.assertEqual(tree.right.attribute, 0)
     self.assertEqual(tree.right.threshold, 4)
コード例 #17
0
 async def test_multiple_samples_with_some_depth(self):
     samples = ObliviousDataset.create(Sample([s(0), s(1)], s(0)),
                                       Sample([s(1), s(0)], s(0)),
                                       Sample([s(1), s(0)], s(0)),
                                       Sample([s(1), s(1)], s(1)))
     self.assertEqual(
         reveal(await train(samples, depth=2)),
         Branch(
             1,
             threshold=0,
             left=Branch(
                 1,  # random, could have been zero as well
                 threshold=0,
                 left=leaf(0),
                 right=pruned()),
             right=Branch(0, threshold=0, left=leaf(0), right=leaf(1))))
コード例 #18
0
 async def test_single_sample_depth_zero_outcome_0(self):
     samples = ObliviousDataset.create(Sample([s(1)], s(0)))
     self.assertEqual(reveal(await train(samples, depth=0)), leaf(0))
コード例 #19
0
from src.dataset import ObliviousDataset, Sample
from src.secint import secint as s


def sample(ins, out):
    return Sample([s(i) for i in ins], s(out))


binary_samples = ObliviousDataset.create(
    sample([1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1], 0),
    sample([1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1], 1),
    sample([1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0], 0),
    sample([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], 1),
    sample([1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], 0),
    sample([1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1], 1),
    sample([1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0], 1),
    sample([1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], 1),
    sample([1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0], 1),
    sample([1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0], 0),
    sample([1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0], 1),
    sample([1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1], 0),
    sample([1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0], 1),
    sample([1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0], 1))

continuous_samples = ObliviousDataset.create(
    sample([1, 1, 1, 2], 1),
    sample([1, 1, 1, 3], 1),
    sample([1, 1, 1, 4], 1),
    sample([1, 1, 3, 1], 1),
    sample([1, 1, 3, 2], 1),
    sample([1, 1, 3, 3], 1),
コード例 #20
0
 async def test_continuous_attributes(self):
     samples = ObliviousDataset.create(Sample([s(1), s(2)], s(0)),
                                       Sample([s(1), s(3)], s(1)),
                                       continuous=[False, True])
     self.assertEqual(reveal(await train(samples, depth=1)),
                      Branch(1, threshold=2, left=leaf(0), right=leaf(1)))
コード例 #21
0
 def test_determine_class_multiple_samples(self):
     dataset = ObliviousDataset.create(Sample([s(0)], s(0)),
                                       Sample([s(0)], s(1)),
                                       Sample([s(0)], s(1)))
     self.assertEqual(reveal(dataset.determine_class()), 1)
コード例 #22
0
 def test_random_sample_with_one_sample(self):
     dataset = ObliviousDataset.create(Sample([s(1), s(2), s(3)], s(4)))
     self.assertEqual(reveal(dataset.choice()), Sample([1, 2, 3], 4))
コード例 #23
0
 def test_number_of_attributes_empty_set(self):
     dataset = ObliviousDataset.create()
     self.assertEqual(dataset.number_of_attributes, 0)
コード例 #24
0
 def test_number_of_attributes(self):
     dataset = ObliviousDataset.create(sample(s(1), s(2), s(3)),
                                       sample(s(4), s(5), s(6)))
     self.assertEqual(dataset.number_of_attributes, 3)
コード例 #25
0
def bootstrap(samples):
    selected_samples = [samples.choice() for _ in range(len(samples))]
    return ObliviousDataset.create(*selected_samples,
                                   continuous=samples.continuous,
                                   labels=samples.labels)
コード例 #26
0
 def test_column_of_subset_with_secret_index(self):
     dataset = ObliviousDataset.create(sample(s(0), s(1), s(2)),
                                       sample(s(10), s(11), s(12)),
                                       sample(s(20), s(21), s(22))).select(
                                           [s(1), s(0), s(1)])
     self.assertEqual(reveal(dataset.column(s(1))), [1, 21])
コード例 #27
0
samples = ObliviousDataset.create(sample([1, 1, 1, 2], 1),
                                  sample([1, 1, 1, 3], 1),
                                  sample([1, 1, 1, 4], 1),
                                  sample([1, 1, 1, 5], 1),
                                  sample([1, 1, 2, 1], 1),
                                  sample([1, 1, 2, 2], 1),
                                  sample([1, 1, 2, 3], 1),
                                  sample([1, 1, 2, 4], 1),
                                  sample([1, 1, 2, 5], 1),
                                  sample([1, 1, 3, 1], 1),
                                  sample([1, 1, 3, 2], 1),
                                  sample([1, 1, 3, 3], 1),
                                  sample([1, 1, 3, 4], 1),
                                  sample([1, 1, 3, 5], 1),
                                  sample([1, 1, 4, 1], 1),
                                  sample([1, 1, 4, 2], 1),
                                  sample([1, 1, 4, 3], 1),
                                  sample([1, 1, 4, 4], 1),
                                  sample([1, 1, 4, 5], 1),
                                  sample([1, 1, 5, 1], 1),
                                  sample([1, 1, 5, 2], 1),
                                  sample([1, 1, 5, 3], 1),
                                  sample([1, 1, 5, 4], 1),
                                  sample([1, 1, 5, 5], 1),
                                  sample([1, 2, 1, 1], 0),
                                  sample([1, 2, 1, 3], 1),
                                  sample([1, 2, 1, 4], 1),
                                  sample([1, 2, 1, 5], 1),
                                  sample([1, 2, 2, 2], 1),
                                  sample([1, 2, 2, 3], 1),
                                  sample([1, 2, 2, 4], 1),
                                  sample([1, 2, 2, 5], 1),
                                  sample([1, 2, 3, 1], 1),
                                  sample([1, 2, 3, 2], 1),
                                  sample([1, 2, 3, 3], 1),
                                  sample([1, 2, 3, 4], 1),
                                  sample([1, 2, 3, 5], 1),
                                  sample([1, 2, 4, 1], 1),
                                  sample([1, 2, 4, 2], 1),
                                  sample([1, 2, 4, 3], 1),
                                  sample([1, 2, 4, 4], 1),
                                  sample([1, 2, 4, 5], 1),
                                  sample([1, 2, 5, 1], 1),
                                  sample([1, 2, 5, 2], 1),
                                  sample([1, 2, 5, 3], 1),
                                  sample([1, 2, 5, 4], 1),
                                  sample([1, 2, 5, 5], 1),
                                  sample([1, 3, 1, 1], 0),
                                  sample([1, 3, 1, 2], 0),
                                  sample([1, 3, 1, 4], 1),
                                  sample([1, 3, 1, 5], 1),
                                  sample([1, 3, 2, 1], 0),
                                  sample([1, 3, 2, 2], 1),
                                  sample([1, 3, 2, 3], 1),
                                  sample([1, 3, 2, 4], 1),
                                  sample([1, 3, 2, 5], 1),
                                  sample([1, 3, 3, 2], 1),
                                  sample([1, 3, 3, 3], 1),
                                  sample([1, 3, 3, 4], 1),
                                  sample([1, 3, 3, 5], 1),
                                  sample([1, 3, 4, 1], 1),
                                  sample([1, 3, 4, 2], 1),
                                  sample([1, 3, 4, 3], 1),
                                  sample([1, 3, 4, 4], 1),
                                  sample([1, 3, 4, 5], 1),
                                  sample([1, 3, 5, 1], 1),
                                  sample([1, 3, 5, 2], 1),
                                  sample([1, 3, 5, 3], 1),
                                  sample([1, 3, 5, 4], 1),
                                  sample([1, 3, 5, 5], 1),
                                  sample([1, 4, 1, 1], 0),
                                  sample([1, 4, 1, 2], 0),
                                  sample([1, 4, 1, 3], 0),
                                  sample([1, 4, 1, 5], 1),
                                  sample([1, 4, 2, 1], 0),
                                  sample([1, 4, 2, 3], 1),
                                  sample([1, 4, 2, 4], 1),
                                  sample([1, 4, 2, 5], 1),
                                  sample([1, 4, 3, 1], 0),
                                  sample([1, 4, 3, 2], 1),
                                  sample([1, 4, 3, 3], 1),
                                  sample([1, 4, 3, 4], 1),
                                  sample([1, 4, 3, 5], 1),
                                  sample([1, 4, 4, 2], 1),
                                  sample([1, 4, 4, 3], 1),
                                  sample([1, 4, 4, 4], 1),
                                  sample([1, 4, 4, 5], 1),
                                  sample([1, 4, 5, 1], 1),
                                  sample([1, 4, 5, 2], 1),
                                  sample([1, 4, 5, 3], 1),
                                  sample([1, 4, 5, 4], 1),
                                  sample([1, 4, 5, 5], 1),
                                  sample([1, 5, 1, 1], 0),
                                  sample([1, 5, 1, 2], 0),
                                  sample([1, 5, 1, 3], 0),
                                  sample([1, 5, 1, 4], 0),
                                  sample([1, 5, 2, 1], 0),
                                  sample([1, 5, 2, 2], 0),
                                  sample([1, 5, 2, 3], 1),
                                  sample([1, 5, 2, 4], 1),
                                  sample([1, 5, 2, 5], 1),
                                  sample([1, 5, 3, 1], 0),
                                  sample([1, 5, 3, 2], 1),
                                  sample([1, 5, 3, 3], 1),
                                  sample([1, 5, 3, 4], 1),
                                  sample([1, 5, 3, 5], 1),
                                  sample([1, 5, 4, 1], 0),
                                  sample([1, 5, 4, 2], 1),
                                  sample([1, 5, 4, 3], 1),
                                  sample([1, 5, 4, 4], 1),
                                  sample([1, 5, 4, 5], 1),
                                  sample([1, 5, 5, 2], 1),
                                  sample([1, 5, 5, 3], 1),
                                  sample([1, 5, 5, 4], 1),
                                  sample([1, 5, 5, 5], 1),
                                  sample([2, 1, 1, 1], 0),
                                  sample([2, 1, 1, 3], 1),
                                  sample([2, 1, 1, 4], 1),
                                  sample([2, 1, 1, 5], 1),
                                  sample([2, 1, 2, 2], 1),
                                  sample([2, 1, 2, 3], 1),
                                  sample([2, 1, 2, 4], 1),
                                  sample([2, 1, 2, 5], 1),
                                  sample([2, 1, 3, 1], 1),
                                  sample([2, 1, 3, 2], 1),
                                  sample([2, 1, 3, 3], 1),
                                  sample([2, 1, 3, 4], 1),
                                  sample([2, 1, 3, 5], 1),
                                  sample([2, 1, 4, 1], 1),
                                  sample([2, 1, 4, 2], 1),
                                  sample([2, 1, 4, 3], 1),
                                  sample([2, 1, 4, 4], 1),
                                  sample([2, 1, 4, 5], 1),
                                  sample([2, 1, 5, 1], 1),
                                  sample([2, 1, 5, 2], 1),
                                  sample([2, 1, 5, 3], 1),
                                  sample([2, 1, 5, 4], 1),
                                  sample([2, 1, 5, 5], 1),
                                  sample([2, 2, 1, 1], 0),
                                  sample([2, 2, 1, 2], 0),
                                  sample([2, 2, 1, 3], 0),
                                  sample([2, 2, 1, 5], 1),
                                  sample([2, 2, 2, 1], 0),
                                  sample([2, 2, 2, 3], 1),
                                  sample([2, 2, 2, 4], 1),
                                  sample([2, 2, 2, 5], 1),
                                  sample([2, 2, 3, 1], 0),
                                  sample([2, 2, 3, 2], 1),
                                  sample([2, 2, 3, 3], 1),
                                  sample([2, 2, 3, 4], 1),
                                  sample([2, 2, 3, 5], 1),
                                  sample([2, 2, 4, 2], 1),
                                  sample([2, 2, 4, 3], 1),
                                  sample([2, 2, 4, 4], 1),
                                  sample([2, 2, 4, 5], 1),
                                  sample([2, 2, 5, 1], 1),
                                  sample([2, 2, 5, 2], 1),
                                  sample([2, 2, 5, 3], 1),
                                  sample([2, 2, 5, 4], 1),
                                  sample([2, 2, 5, 5], 1),
                                  sample([2, 3, 1, 1], 0),
                                  sample([2, 3, 1, 2], 0),
                                  sample([2, 3, 1, 3], 0),
                                  sample([2, 3, 1, 4], 0),
                                  sample([2, 3, 1, 5], 0),
                                  sample([2, 3, 2, 1], 0),
                                  sample([2, 3, 2, 2], 0),
                                  sample([2, 3, 2, 4], 1),
                                  sample([2, 3, 2, 5], 1),
                                  sample([2, 3, 3, 1], 0),
                                  sample([2, 3, 3, 3], 1),
                                  sample([2, 3, 3, 4], 1),
                                  sample([2, 3, 3, 5], 1),
                                  sample([2, 3, 4, 1], 0),
                                  sample([2, 3, 4, 2], 1),
                                  sample([2, 3, 4, 3], 1),
                                  sample([2, 3, 4, 4], 1),
                                  sample([2, 3, 4, 5], 1),
                                  sample([2, 3, 5, 1], 0),
                                  sample([2, 3, 5, 2], 1),
                                  sample([2, 3, 5, 3], 1),
                                  sample([2, 3, 5, 4], 1),
                                  sample([2, 3, 5, 5], 1),
                                  sample([2, 4, 1, 1], 0),
                                  sample([2, 4, 1, 2], 0),
                                  sample([2, 4, 1, 3], 0),
                                  sample([2, 4, 1, 4], 0),
                                  sample([2, 4, 1, 5], 0),
                                  sample([2, 4, 2, 1], 0),
                                  sample([2, 4, 2, 2], 0),
                                  sample([2, 4, 2, 3], 0),
                                  sample([2, 4, 2, 5], 1),
                                  sample([2, 4, 3, 1], 0),
                                  sample([2, 4, 3, 2], 0),
                                  sample([2, 4, 3, 3], 1),
                                  sample([2, 4, 3, 4], 1),
                                  sample([2, 4, 3, 5], 1),
                                  sample([2, 4, 4, 1], 0),
                                  sample([2, 4, 4, 3], 1),
                                  sample([2, 4, 4, 4], 1),
                                  sample([2, 4, 4, 5], 1),
                                  sample([2, 4, 5, 1], 0),
                                  sample([2, 4, 5, 2], 1),
                                  sample([2, 4, 5, 3], 1),
                                  sample([2, 4, 5, 4], 1),
                                  sample([2, 4, 5, 5], 1),
                                  sample([2, 5, 1, 1], 0),
                                  sample([2, 5, 1, 2], 0),
                                  sample([2, 5, 1, 3], 0),
                                  sample([2, 5, 1, 4], 0),
                                  sample([2, 5, 1, 5], 0),
                                  sample([2, 5, 2, 1], 0),
                                  sample([2, 5, 2, 2], 0),
                                  sample([2, 5, 2, 3], 0),
                                  sample([2, 5, 2, 4], 0),
                                  sample([2, 5, 3, 1], 0),
                                  sample([2, 5, 3, 2], 0),
                                  sample([2, 5, 3, 3], 0),
                                  sample([2, 5, 3, 4], 1),
                                  sample([2, 5, 3, 5], 1),
                                  sample([2, 5, 4, 1], 0),
                                  sample([2, 5, 4, 2], 0),
                                  sample([2, 5, 4, 3], 1),
                                  sample([2, 5, 4, 4], 1),
                                  sample([2, 5, 4, 5], 1),
                                  sample([2, 5, 5, 1], 0),
                                  sample([2, 5, 5, 3], 1),
                                  sample([2, 5, 5, 4], 1),
                                  sample([2, 5, 5, 5], 1),
                                  sample([3, 1, 1, 1], 0),
                                  sample([3, 1, 1, 2], 0),
                                  sample([3, 1, 1, 4], 1),
                                  sample([3, 1, 1, 5], 1),
                                  sample([3, 1, 2, 1], 0),
                                  sample([3, 1, 2, 2], 1),
                                  sample([3, 1, 2, 3], 1),
                                  sample([3, 1, 2, 4], 1),
                                  sample([3, 1, 2, 5], 1),
                                  sample([3, 1, 3, 2], 1),
                                  sample([3, 1, 3, 3], 1),
                                  sample([3, 1, 3, 4], 1),
                                  sample([3, 1, 3, 5], 1),
                                  sample([3, 1, 4, 1], 1),
                                  sample([3, 1, 4, 2], 1),
                                  sample([3, 1, 4, 3], 1),
                                  sample([3, 1, 4, 4], 1),
                                  sample([3, 1, 4, 5], 1),
                                  sample([3, 1, 5, 1], 1),
                                  sample([3, 1, 5, 2], 1),
                                  sample([3, 1, 5, 3], 1),
                                  sample([3, 1, 5, 4], 1),
                                  sample([3, 1, 5, 5], 1),
                                  sample([3, 2, 1, 1], 0),
                                  sample([3, 2, 1, 2], 0),
                                  sample([3, 2, 1, 3], 0),
                                  sample([3, 2, 1, 4], 0),
                                  sample([3, 2, 1, 5], 0),
                                  sample([3, 2, 2, 1], 0),
                                  sample([3, 2, 2, 2], 0),
                                  sample([3, 2, 2, 4], 1),
                                  sample([3, 2, 2, 5], 1),
                                  sample([3, 2, 3, 1], 0),
                                  sample([3, 2, 3, 3], 1),
                                  sample([3, 2, 3, 4], 1),
                                  sample([3, 2, 3, 5], 1),
                                  sample([3, 2, 4, 1], 0),
                                  sample([3, 2, 4, 2], 1),
                                  sample([3, 2, 4, 3], 1),
                                  sample([3, 2, 4, 4], 1),
                                  sample([3, 2, 4, 5], 1),
                                  sample([3, 2, 5, 1], 0),
                                  sample([3, 2, 5, 2], 1),
                                  sample([3, 2, 5, 3], 1),
                                  sample([3, 2, 5, 4], 1),
                                  sample([3, 2, 5, 5], 1),
                                  sample([3, 3, 1, 1], 0),
                                  sample([3, 3, 1, 2], 0),
                                  sample([3, 3, 1, 3], 0),
                                  sample([3, 3, 1, 4], 0),
                                  sample([3, 3, 1, 5], 0),
                                  sample([3, 3, 2, 1], 0),
                                  sample([3, 3, 2, 2], 0),
                                  sample([3, 3, 2, 3], 0),
                                  sample([3, 3, 2, 4], 0),
                                  sample([3, 3, 2, 5], 1),
                                  sample([3, 3, 3, 1], 0),
                                  sample([3, 3, 3, 2], 0),
                                  sample([3, 3, 3, 4], 1),
                                  sample([3, 3, 3, 5], 1),
                                  sample([3, 3, 4, 1], 0),
                                  sample([3, 3, 4, 2], 0),
                                  sample([3, 3, 4, 3], 1),
                                  sample([3, 3, 4, 4], 1),
                                  sample([3, 3, 4, 5], 1),
                                  sample([3, 3, 5, 1], 0),
                                  sample([3, 3, 5, 2], 1),
                                  sample([3, 3, 5, 3], 1),
                                  sample([3, 3, 5, 4], 1),
                                  sample([3, 3, 5, 5], 1),
                                  sample([3, 4, 1, 1], 0),
                                  sample([3, 4, 1, 2], 0),
                                  sample([3, 4, 1, 3], 0),
                                  sample([3, 4, 1, 4], 0),
                                  sample([3, 4, 1, 5], 0),
                                  sample([3, 4, 2, 1], 0),
                                  sample([3, 4, 2, 2], 0),
                                  sample([3, 4, 2, 3], 0),
                                  sample([3, 4, 2, 4], 0),
                                  sample([3, 4, 2, 5], 0),
                                  sample([3, 4, 3, 1], 0),
                                  sample([3, 4, 3, 2], 0),
                                  sample([3, 4, 3, 3], 0),
                                  sample([3, 4, 3, 5], 1),
                                  sample([3, 4, 4, 1], 0),
                                  sample([3, 4, 4, 2], 0),
                                  sample([3, 4, 4, 4], 1),
                                  sample([3, 4, 4, 5], 1),
                                  sample([3, 4, 5, 1], 0),
                                  sample([3, 4, 5, 2], 0),
                                  sample([3, 4, 5, 3], 1),
                                  sample([3, 4, 5, 4], 1),
                                  sample([3, 4, 5, 5], 1),
                                  sample([3, 5, 1, 1], 0),
                                  sample([3, 5, 1, 2], 0),
                                  sample([3, 5, 1, 3], 0),
                                  sample([3, 5, 1, 4], 0),
                                  sample([3, 5, 1, 5], 0),
                                  sample([3, 5, 2, 1], 0),
                                  sample([3, 5, 2, 2], 0),
                                  sample([3, 5, 2, 3], 0),
                                  sample([3, 5, 2, 4], 0),
                                  sample([3, 5, 2, 5], 0),
                                  sample([3, 5, 3, 1], 0),
                                  sample([3, 5, 3, 2], 0),
                                  sample([3, 5, 3, 3], 0),
                                  sample([3, 5, 3, 4], 0),
                                  sample([3, 5, 4, 1], 0),
                                  sample([3, 5, 4, 2], 0),
                                  sample([3, 5, 4, 3], 0),
                                  sample([3, 5, 4, 4], 1),
                                  sample([3, 5, 4, 5], 1),
                                  sample([3, 5, 5, 1], 0),
                                  sample([3, 5, 5, 2], 0),
                                  sample([3, 5, 5, 4], 1),
                                  sample([3, 5, 5, 5], 1),
                                  sample([4, 1, 1, 1], 0),
                                  sample([4, 1, 1, 2], 0),
                                  sample([4, 1, 1, 3], 0),
                                  sample([4, 1, 1, 5], 1),
                                  sample([4, 1, 2, 1], 0),
                                  sample([4, 1, 2, 3], 1),
                                  sample([4, 1, 2, 4], 1),
                                  sample([4, 1, 2, 5], 1),
                                  sample([4, 1, 3, 1], 0),
                                  sample([4, 1, 3, 2], 1),
                                  sample([4, 1, 3, 3], 1),
                                  sample([4, 1, 3, 4], 1),
                                  sample([4, 1, 3, 5], 1),
                                  sample([4, 1, 4, 2], 1),
                                  sample([4, 1, 4, 3], 1),
                                  sample([4, 1, 4, 4], 1),
                                  sample([4, 1, 4, 5], 1),
                                  sample([4, 1, 5, 1], 1),
                                  sample([4, 1, 5, 2], 1),
                                  sample([4, 1, 5, 3], 1),
                                  sample([4, 1, 5, 4], 1),
                                  sample([4, 1, 5, 5], 1),
                                  sample([4, 2, 1, 1], 0),
                                  sample([4, 2, 1, 2], 0),
                                  sample([4, 2, 1, 3], 0),
                                  sample([4, 2, 1, 4], 0),
                                  sample([4, 2, 1, 5], 0),
                                  sample([4, 2, 2, 1], 0),
                                  sample([4, 2, 2, 2], 0),
                                  sample([4, 2, 2, 3], 0),
                                  sample([4, 2, 2, 5], 1),
                                  sample([4, 2, 3, 1], 0),
                                  sample([4, 2, 3, 2], 0),
                                  sample([4, 2, 3, 3], 1),
                                  sample([4, 2, 3, 4], 1),
                                  sample([4, 2, 3, 5], 1),
                                  sample([4, 2, 4, 1], 0),
                                  sample([4, 2, 4, 3], 1),
                                  sample([4, 2, 4, 4], 1),
                                  sample([4, 2, 4, 5], 1),
                                  sample([4, 2, 5, 1], 0),
                                  sample([4, 2, 5, 2], 1),
                                  sample([4, 2, 5, 3], 1),
                                  sample([4, 2, 5, 4], 1),
                                  sample([4, 2, 5, 5], 1),
                                  sample([4, 3, 1, 1], 0),
                                  sample([4, 3, 1, 2], 0),
                                  sample([4, 3, 1, 3], 0),
                                  sample([4, 3, 1, 4], 0),
                                  sample([4, 3, 1, 5], 0),
                                  sample([4, 3, 2, 1], 0),
                                  sample([4, 3, 2, 2], 0),
                                  sample([4, 3, 2, 3], 0),
                                  sample([4, 3, 2, 4], 0),
                                  sample([4, 3, 2, 5], 0),
                                  sample([4, 3, 3, 1], 0),
                                  sample([4, 3, 3, 2], 0),
                                  sample([4, 3, 3, 3], 0),
                                  sample([4, 3, 3, 5], 1),
                                  sample([4, 3, 4, 1], 0),
                                  sample([4, 3, 4, 2], 0),
                                  sample([4, 3, 4, 4], 1),
                                  sample([4, 3, 4, 5], 1),
                                  sample([4, 3, 5, 1], 0),
                                  sample([4, 3, 5, 2], 0),
                                  sample([4, 3, 5, 3], 1),
                                  sample([4, 3, 5, 4], 1),
                                  sample([4, 3, 5, 5], 1),
                                  sample([4, 4, 1, 1], 0),
                                  sample([4, 4, 1, 2], 0),
                                  sample([4, 4, 1, 3], 0),
                                  sample([4, 4, 1, 4], 0),
                                  sample([4, 4, 1, 5], 0),
                                  sample([4, 4, 2, 1], 0),
                                  sample([4, 4, 2, 2], 0),
                                  sample([4, 4, 2, 3], 0),
                                  sample([4, 4, 2, 4], 0),
                                  sample([4, 4, 2, 5], 0),
                                  sample([4, 4, 3, 1], 0),
                                  sample([4, 4, 3, 2], 0),
                                  sample([4, 4, 3, 3], 0),
                                  sample([4, 4, 3, 4], 0),
                                  sample([4, 4, 3, 5], 0),
                                  sample([4, 4, 4, 1], 0),
                                  sample([4, 4, 4, 2], 0),
                                  sample([4, 4, 4, 3], 0),
                                  sample([4, 4, 4, 5], 1),
                                  sample([4, 4, 5, 1], 0),
                                  sample([4, 4, 5, 2], 0),
                                  sample([4, 4, 5, 3], 0),
                                  sample([4, 4, 5, 4], 1),
                                  sample([4, 4, 5, 5], 1),
                                  sample([4, 5, 1, 1], 0),
                                  sample([4, 5, 1, 2], 0),
                                  sample([4, 5, 1, 3], 0),
                                  sample([4, 5, 1, 4], 0),
                                  sample([4, 5, 1, 5], 0),
                                  sample([4, 5, 2, 1], 0),
                                  sample([4, 5, 2, 2], 0),
                                  sample([4, 5, 2, 3], 0),
                                  sample([4, 5, 2, 4], 0),
                                  sample([4, 5, 2, 5], 0),
                                  sample([4, 5, 3, 1], 0),
                                  sample([4, 5, 3, 2], 0),
                                  sample([4, 5, 3, 3], 0),
                                  sample([4, 5, 3, 4], 0),
                                  sample([4, 5, 3, 5], 0),
                                  sample([4, 5, 4, 1], 0),
                                  sample([4, 5, 4, 2], 0),
                                  sample([4, 5, 4, 3], 0),
                                  sample([4, 5, 4, 4], 0),
                                  sample([4, 5, 5, 1], 0),
                                  sample([4, 5, 5, 2], 0),
                                  sample([4, 5, 5, 3], 0),
                                  sample([4, 5, 5, 5], 1),
                                  sample([5, 1, 1, 1], 0),
                                  sample([5, 1, 1, 2], 0),
                                  sample([5, 1, 1, 3], 0),
                                  sample([5, 1, 1, 4], 0),
                                  sample([5, 1, 2, 1], 0),
                                  sample([5, 1, 2, 2], 0),
                                  sample([5, 1, 2, 3], 1),
                                  sample([5, 1, 2, 4], 1),
                                  sample([5, 1, 2, 5], 1),
                                  sample([5, 1, 3, 1], 0),
                                  sample([5, 1, 3, 2], 1),
                                  sample([5, 1, 3, 3], 1),
                                  sample([5, 1, 3, 4], 1),
                                  sample([5, 1, 3, 5], 1),
                                  sample([5, 1, 4, 1], 0),
                                  sample([5, 1, 4, 2], 1),
                                  sample([5, 1, 4, 3], 1),
                                  sample([5, 1, 4, 4], 1),
                                  sample([5, 1, 4, 5], 1),
                                  sample([5, 1, 5, 2], 1),
                                  sample([5, 1, 5, 3], 1),
                                  sample([5, 1, 5, 4], 1),
                                  sample([5, 1, 5, 5], 1),
                                  sample([5, 2, 1, 1], 0),
                                  sample([5, 2, 1, 2], 0),
                                  sample([5, 2, 1, 3], 0),
                                  sample([5, 2, 1, 4], 0),
                                  sample([5, 2, 1, 5], 0),
                                  sample([5, 2, 2, 1], 0),
                                  sample([5, 2, 2, 2], 0),
                                  sample([5, 2, 2, 3], 0),
                                  sample([5, 2, 2, 4], 0),
                                  sample([5, 2, 3, 1], 0),
                                  sample([5, 2, 3, 2], 0),
                                  sample([5, 2, 3, 3], 0),
                                  sample([5, 2, 3, 4], 1),
                                  sample([5, 2, 3, 5], 1),
                                  sample([5, 2, 4, 1], 0),
                                  sample([5, 2, 4, 2], 0),
                                  sample([5, 2, 4, 3], 1),
                                  sample([5, 2, 4, 4], 1),
                                  sample([5, 2, 4, 5], 1),
                                  sample([5, 2, 5, 1], 0),
                                  sample([5, 2, 5, 3], 1),
                                  sample([5, 2, 5, 4], 1),
                                  sample([5, 2, 5, 5], 1),
                                  sample([5, 3, 1, 1], 0),
                                  sample([5, 3, 1, 2], 0),
                                  sample([5, 3, 1, 3], 0),
                                  sample([5, 3, 1, 4], 0),
                                  sample([5, 3, 1, 5], 0),
                                  sample([5, 3, 2, 1], 0),
                                  sample([5, 3, 2, 2], 0),
                                  sample([5, 3, 2, 3], 0),
                                  sample([5, 3, 2, 4], 0),
                                  sample([5, 3, 2, 5], 0),
                                  sample([5, 3, 3, 1], 0),
                                  sample([5, 3, 3, 2], 0),
                                  sample([5, 3, 3, 3], 0),
                                  sample([5, 3, 3, 4], 0),
                                  sample([5, 3, 4, 1], 0),
                                  sample([5, 3, 4, 2], 0),
                                  sample([5, 3, 4, 3], 0),
                                  sample([5, 3, 4, 4], 1),
                                  sample([5, 3, 4, 5], 1),
                                  sample([5, 3, 5, 1], 0),
                                  sample([5, 3, 5, 2], 0),
                                  sample([5, 3, 5, 4], 1),
                                  sample([5, 3, 5, 5], 1),
                                  sample([5, 4, 1, 1], 0),
                                  sample([5, 4, 1, 2], 0),
                                  sample([5, 4, 1, 3], 0),
                                  sample([5, 4, 1, 4], 0),
                                  sample([5, 4, 1, 5], 0),
                                  sample([5, 4, 2, 1], 0),
                                  sample([5, 4, 2, 2], 0),
                                  sample([5, 4, 2, 3], 0),
                                  sample([5, 4, 2, 4], 0),
                                  sample([5, 4, 2, 5], 0),
                                  sample([5, 4, 3, 1], 0),
                                  sample([5, 4, 3, 2], 0),
                                  sample([5, 4, 3, 3], 0),
                                  sample([5, 4, 3, 4], 0),
                                  sample([5, 4, 3, 5], 0),
                                  sample([5, 4, 4, 1], 0),
                                  sample([5, 4, 4, 2], 0),
                                  sample([5, 4, 4, 3], 0),
                                  sample([5, 4, 4, 4], 0),
                                  sample([5, 4, 5, 1], 0),
                                  sample([5, 4, 5, 2], 0),
                                  sample([5, 4, 5, 3], 0),
                                  sample([5, 4, 5, 5], 1),
                                  sample([5, 5, 1, 1], 0),
                                  sample([5, 5, 1, 2], 0),
                                  sample([5, 5, 1, 3], 0),
                                  sample([5, 5, 1, 4], 0),
                                  sample([5, 5, 1, 5], 0),
                                  sample([5, 5, 2, 1], 0),
                                  sample([5, 5, 2, 2], 0),
                                  sample([5, 5, 2, 3], 0),
                                  sample([5, 5, 2, 4], 0),
                                  sample([5, 5, 2, 5], 0),
                                  sample([5, 5, 3, 1], 0),
                                  sample([5, 5, 3, 2], 0),
                                  sample([5, 5, 3, 3], 0),
                                  sample([5, 5, 3, 4], 0),
                                  sample([5, 5, 3, 5], 0),
                                  sample([5, 5, 4, 1], 0),
                                  sample([5, 5, 4, 2], 0),
                                  sample([5, 5, 4, 3], 0),
                                  sample([5, 5, 4, 4], 0),
                                  sample([5, 5, 4, 5], 0),
                                  sample([5, 5, 5, 1], 0),
                                  sample([5, 5, 5, 2], 0),
                                  sample([5, 5, 5, 3], 0),
                                  sample([5, 5, 5, 4], 0),
                                  continuous=[True, True, True, True])
コード例 #28
0
 async def test_two_samples_two_attributes(self):
     samples = ObliviousDataset.create(Sample([s(1), s(0)], s(0)),
                                       Sample([s(1), s(1)], s(1)))
     self.assertEqual(reveal(await train(samples, depth=1)),
                      Branch(1, threshold=0, left=leaf(0), right=leaf(1)))