Exemplo n.º 1
0
def test_slicing():
    train_index = np.array(range(100))
    test_index = np.array(range(100, 250))

    d = Dataset(X_train, y_train, X_test, y_test)

    Xtrain, ytrain, Xtest, ytest = d.split(indices=(train_index, test_index))
    assert Xtrain.shape[0] == 100
    assert ytrain.shape[0] == Xtrain.shape[0]

    assert Xtest.shape[0] == 150
    assert Xtest.shape[0] == ytest.shape[0]

    d = Dataset(pd.DataFrame(X_train), pd.DataFrame(y_train), pd.DataFrame(X_test), pd.DataFrame(y_test))
    Xtrain, ytrain, Xtest, ytest = d.split(indices=(train_index, test_index))
    assert Xtrain.shape[0] == 100
    assert ytrain.shape[0] == Xtrain.shape[0]

    assert Xtest.shape[0] == 150
    assert Xtest.shape[0] == ytest.shape[0]
Exemplo n.º 2
0
def test_split():
    d = Dataset(X_train, y_train)
    d.split(inplace=True)
    assert d.X_test is not None
    assert d.y_test is not None

    d = Dataset(X_train, y_train)
    data = d.split(inplace=False)
    assert all(x is not None for x in data)

    d = Dataset(X_train, y_train)
    data = d.split(inplace=False)
    assert all([x is not None for x in data])

    d = Dataset(pd.DataFrame(X_train), pd.DataFrame(y_train))
    train_ind = np.array(range(0, 70))
    test_ind = np.array(range(30, 100))
    data = d.split(indices=[train_ind, test_ind])
    assert isinstance(data[0], (pd.DataFrame, pd.Series))
    assert isinstance(data[2], (pd.DataFrame, pd.Series))
Exemplo n.º 3
0
def test_split():
    d = Dataset(X_train, y_train)
    d.split(inplace=True)
    assert d.X_test is not None
    assert d.y_test is not None

    d = Dataset(X_train, y_train)
    data = d.split(inplace=False)
    assert all(x is not None for x in data)

    d = Dataset(X_train, y_train)
    data = d.split(inplace=False)
    assert all([x is not None for x in data])

    d = Dataset(pd.DataFrame(X_train), pd.DataFrame(y_train))
    train_ind = np.array(range(0, 70))
    test_ind = np.array(range(30, 100))
    data = d.split(indices=[train_ind, test_ind])
    assert isinstance(data[0], (pd.DataFrame, pd.Series))
    assert isinstance(data[2], (pd.DataFrame, pd.Series))
Exemplo n.º 4
0
def test_slicing():
    train_index = np.array(range(100))
    test_index = np.array(range(100, 250))

    d = Dataset(X_train, y_train, X_test, y_test)

    Xtrain, ytrain, Xtest, ytest = d.split(indices=(train_index, test_index))
    assert Xtrain.shape[0] == 100
    assert ytrain.shape[0] == Xtrain.shape[0]

    assert Xtest.shape[0] == 150
    assert Xtest.shape[0] == ytest.shape[0]

    d = Dataset(pd.DataFrame(X_train), pd.DataFrame(y_train),
                pd.DataFrame(X_test), pd.DataFrame(y_test))
    Xtrain, ytrain, Xtest, ytest = d.split(indices=(train_index, test_index))
    assert Xtrain.shape[0] == 100
    assert ytrain.shape[0] == Xtrain.shape[0]

    assert Xtest.shape[0] == 150
    assert Xtest.shape[0] == ytest.shape[0]