def test_splits():
    oob = BootstrapOutOfBag(n_splits=3, random_seed=123)
    results = list(oob.split(np.array([1, 2, 3, 4, 5])))
    assert len(results) == 3
    assert np.array_equal(results[0][0], np.array([2, 4, 2, 1, 3]))
    assert np.array_equal(results[0][1], np.array([0]))
    assert np.array_equal(results[-1][0], np.array([1, 1, 0, 0, 1]))
    assert np.array_equal(results[-1][1], np.array([2, 3, 4]))
Ejemplo n.º 2
0
def test_splits():
    oob = BootstrapOutOfBag(n_splits=3, random_seed=123)
    results = list(oob.split(np.array([1, 2, 3, 4, 5])))
    assert len(results) == 3
    assert np.array_equal(results[0][0], np.array([2, 4, 2, 1, 3]))
    assert np.array_equal(results[0][1], np.array([0]))
    assert np.array_equal(results[-1][0], np.array([1, 1, 0, 0, 1]))
    assert np.array_equal(results[-1][1], np.array([2, 3, 4]))
    def get_bootstrap(X: np.ndarray, y: np.ndarray, n: int = 200):
        """Returns train, test, validation splits

        Arguments:
            X {np.ndarray} -- Feature matrix
            y {np.ndarray} -- Label vector
            n {int} -- number of bootstrap resamplings
        """

        assert len(X) == len(y)

        bs = BootstrapOutOfBag(n_splits=n, random_seed=RANDOM_SEED)

        oob = bs.split(np.arange(len(y)))

        return oob
def test_get_n_splits():
    oob = BootstrapOutOfBag(n_splits=3, random_seed=123)
    assert oob.n_splits == 3
def test_defaults():
    oob = BootstrapOutOfBag()
    results = list(oob.split(np.array([1, 2, 3, 4, 5])))
    assert len(results) == 200
Ejemplo n.º 6
0
def test_defaults():
    oob = BootstrapOutOfBag()
    results = list(oob.split(np.array([1, 2, 3, 4, 5])))
    assert len(results) == 200