Пример #1
0
def test_NearestNeighbourImputerRowsCleanValueError():
    rnd = np.random.RandomState(SEED)
    X = np.ma.MaskedArray(data=rnd.randn(100, 3), mask=True)
    imputer = NearestNeighboursImputer(nodes=100, k=5)
    X.mask[:10, :2] = False
    with pytest.raises(ValueError):
        imputer(X)
Пример #2
0
def test_NearestNeighbourImputer(make_missing_data):

    X = make_missing_data
    Xcopy = X.copy()

    imputer = NearestNeighboursImputer(nodes=100)
    # imputer(nn) what's this doing here?

    Ximp = imputer(X)

    assert np.all(~np.isnan(Ximp))
    assert np.all(~np.isinf(Ximp))
    assert Ximp.shape == Xcopy.shape
    assert np.ma.count_masked(Ximp) == 0
Пример #3
0
def test_NearestNeighbourImputer(make_missing_data):

    X = make_missing_data
    Xcopy = X.copy()
    # nn = np.ma.MaskedArray(data=np.random.randn(100, 2), mask=False)

    imputer = NearestNeighboursImputer(nodes=100)
    # imputer(nn) what's this doing here?

    Ximp = imputer(X)

    assert np.all(~np.isnan(Ximp))
    assert np.all(~np.isinf(Ximp))
    assert Ximp.shape == Xcopy.shape
    assert np.ma.count_masked(Ximp) == 0
Пример #4
0
def test_NearestNeighbourImputerValueError():
    X = np.ma.MaskedArray(data=np.random.randn(100, 3), mask=True)
    imputer = NearestNeighboursImputer(nodes=100, k=5)
    X.mask[:4, :] = False
    with pytest.raises(ValueError):
        Ximp = imputer(X)