Exemplo n.º 1
0
    def testKFoldsRandomize(self):
        kfolds = data_split.KFolds(2)

        partition1 = kfolds.split(range(10))
        partition2 = kfolds.split(range(10), randomize=True)

        self.assertNotEqual(partition1, partition2)
        self.assertItemsEqual(partition1[0][0] + partition1[0][1],
                              partition2[0][0] + partition2[0][1])
Exemplo n.º 2
0
    def testKFolds2(self):
        kfolds = data_split.KFolds(2)

        with self.assertRaises(ValueError):
            kfolds.split(xrange(1))

        self.assertSequenceEqual(kfolds.split(xrange(2)), [([1], [0]),
                                                           ([0], [1])])

        self.assertSequenceEqual(kfolds.split(xrange(3)), [([1, 2], [0]),
                                                           ([0, 2], [1])])
Exemplo n.º 3
0
 def testKFoldsBadKValue(self):
   with self.assertRaises(ValueError):
     data_split.KFolds(1)
Exemplo n.º 4
0
 def testKFoldsBadKType(self):
   with self.assertRaises(TypeError):
     data_split.KFolds(3.0)