Beispiel #1
0
    def testSplitDataset_fractions(self):
        h = [0, 1, 2, 3]
        listdataset = dataset.ListDataset(elem_list=h)
        splitdataset = dataset.SplitDataset(listdataset, {
            'train': 0.75,
            'val': 0.25
        })

        splitdataset.select('train')
        self.assertEqual(len(splitdataset), 3)
        self.assertEqual(splitdataset[2], 2)

        splitdataset.select('val')
        self.assertEqual(len(splitdataset), 1)
        self.assertEqual(splitdataset[0], 3)
Beispiel #2
0
    def testSplitDataset(self):
        h = [0, 1, 2, 3]
        listdataset = dataset.ListDataset(elem_list=h)
        splitdataset = dataset.SplitDataset(listdataset, {
            'train': 3,
            'val': 1
        })

        splitdataset.select('train')
        self.assertEqual(len(splitdataset), 3)
        self.assertEqual(splitdataset[2], 2)

        splitdataset.select('val')
        self.assertEqual(len(splitdataset), 1)
        self.assertEqual(splitdataset[0], 3)

        # test fluent api
        splitdataset = listdataset.split({'train': 3, 'val': 1})
        splitdataset.select('train')
        self.assertEqual(len(splitdataset), 3)
        self.assertEqual(splitdataset[2], 2)
Beispiel #3
0
    def testSplitDataset(self):
        h = [0, 1, 2, 3]
        listdataset = dataset.ListDataset(elem_list=h)
        splitdataset = dataset.SplitDataset(listdataset, {
            "train": 3,
            "val": 1
        })

        splitdataset.select("train")
        self.assertEqual(len(splitdataset), 3)
        self.assertEqual(splitdataset[2], 2)

        splitdataset.select("val")
        self.assertEqual(len(splitdataset), 1)
        self.assertEqual(splitdataset[0], 3)

        # test fluent api
        splitdataset = listdataset.split({"train": 3, "val": 1})
        splitdataset.select("train")
        self.assertEqual(len(splitdataset), 3)
        self.assertEqual(splitdataset[2], 2)