def test_random_split_4(interactions_ds): """Test with half of the records sampled to the test set.""" train_ds, test_ds = random_split(interactions_ds, test_ratio=0.5, seed=0) assert [[1, 2, 3, 100, 0], [1, 4, 5, 50, 1], [1, 5, 2, 25, 2]] == train_ds.values_list(to_list=True) assert [[2, 2, 5, 100, 3], [2, 3, 2, 20, 4]] == test_ds.values_list(to_list=True)
def test_random_split_3(interactions_ds): """Test if error is thrown with an invalid value of test_ratio (> 1).""" try: random_split(interactions_ds, test_ratio=2) except Exception as e: assert str(e) == 'The test_ratio argument must be in the (0, 1) range.'