def test_predict_wrong_X_dimensions(self):
rs = np.random.RandomState(1)
model = RandomForestWithInstances(np.zeros((10,), dtype=np.uint), bounds=np.array(
list(map(lambda x: (0, 10), range(10))), dtype=object))
X = rs.rand(10)
self.assertRaisesRegexp(ValueError, "Expected 2d array, got 1d array!",
model.predict, X)
X = rs.rand(10, 10, 10)
self.assertRaisesRegexp(ValueError, "Expected 2d array, got 3d array!",
model.predict, X)
X = rs.rand(10, 5)
self.assertRaisesRegexp(ValueError, "Rows in X should have 10 entries "
"but have 5!",
model.predict, X)
评论列表
文章目录