Пример #1
0
def test_kbinsdiscretizer(
        blobs_dataset,
        n_bins,  # noqa: F811
        encode,
        strategy):
    X_np, X = blobs_dataset

    transformer = cuKBinsDiscretizer(n_bins=n_bins,
                                     encode=encode,
                                     strategy=strategy)
    t_X = transformer.fit_transform(X)
    r_X = transformer.inverse_transform(t_X)

    if encode != 'onehot':
        assert type(t_X) == type(X)
        assert type(r_X) == type(t_X)

    transformer = skKBinsDiscretizer(n_bins=n_bins,
                                     encode=encode,
                                     strategy=strategy)
    sk_t_X = transformer.fit_transform(X_np)
    sk_r_X = transformer.inverse_transform(sk_t_X)

    if strategy == 'kmeans':
        assert_allclose(t_X, sk_t_X, ratio_tol=0.2)
    else:
        assert_allclose(t_X, sk_t_X)
        assert_allclose(r_X, sk_r_X)
Пример #2
0
def test__repr__():
    assert cuStandardScaler().__repr__() == 'StandardScaler()'
    assert cuMinMaxScaler().__repr__() == 'MinMaxScaler()'
    assert cuMaxAbsScaler().__repr__() == 'MaxAbsScaler()'
    assert cuNormalizer().__repr__() == 'Normalizer()'
    assert cuBinarizer().__repr__() == 'Binarizer()'
    assert cuPolynomialFeatures().__repr__() == 'PolynomialFeatures()'
    assert cuSimpleImputer().__repr__() == 'SimpleImputer()'
    assert cuRobustScaler().__repr__() == 'RobustScaler()'
    assert cuKBinsDiscretizer().__repr__() == 'KBinsDiscretizer()'