def testTypeOfTarget(self): raws = [ np.array([[0, 1], [0, 0]]), # multilabel np.random.randint(2, size=(5, 3, 3)), # ndim > 2, unknown np.array([[]]), # ndim == 2, shape[1] == 0, unknown np.array([[1, 2], [1, 2]]), np.array([1, 2, 3]), np.array([.1, .2, 3]), np.array([[.1, .2, 3]]), np.array([[1., .2]]), np.array([[1., 2., 3]]), np.array([[1, 2]]), np.array([1, 2]), np.array([["a"], ["b"]], dtype=object), [[1, 2]], [], # empty list ] for raw in raws: self.assertEqual(type_of_target(raw).execute(), sklearn_type_of_target(raw)) t = mt.tensor(raws[0], chunk_size=1) self.assertEqual(type_of_target(t).execute(), sklearn_type_of_target(raws[0])) with self.assertRaises(ValueError): type_of_target('sth')
def test_type_of_target(setup): raws = [ np.array([[0, 1], [0, 0]]), # multilabel np.random.randint(2, size=(5, 3, 3)), # ndim > 2, unknown np.array([[]]), # ndim == 2, shape[1] == 0, unknown np.array([[1, 2], [1, 2]]), np.array([1, 2, 3]), np.array([.1, .2, 3]), np.array([[.1, .2, 3]]), np.array([[1., .2]]), np.array([[1., 2., 3]]), np.array([[1, 2]]), np.array([1, 2]), np.array([["a"], ["b"]], dtype=object), [[1, 2]], [], # empty list ] for raw in raws: assert type_of_target(raw).to_numpy() == sklearn_type_of_target(raw) t = mt.tensor(raws[0], chunk_size=1) assert type_of_target(t).to_numpy() == sklearn_type_of_target(raws[0]) with pytest.raises(ValueError): type_of_target('sth')