|
10 | 10 | from cuml.preprocessing._target_encoder import TargetEncoder |
11 | 11 | from cuml.testing.utils import array_equal |
12 | 12 |
|
13 | | -# Filter the combination mode deprecation warning for all tests in this module |
14 | | -pytestmark = pytest.mark.filterwarnings( |
15 | | - "ignore:TargetEncoder currently returns 1D output:FutureWarning" |
16 | | -) |
17 | | - |
18 | 13 | # TODO: many of these tests use `output_type="numpy"` to work around |
19 | 14 | # https://github.com/rapidsai/cuml/issues/7893. These can be |
20 | 15 | # reverted once that's resolved. |
21 | 16 |
|
22 | 17 |
|
23 | | -def test_targetencoder_deprecated_1d_input(): |
24 | | - df = cudf.DataFrame( |
25 | | - {"category": ["a", "b", "b", "a"], "label": [1, 0, 1, 1]} |
26 | | - ) |
27 | | - |
28 | | - # Warns in fit_transform |
29 | | - encoder = TargetEncoder(output_type="numpy") |
30 | | - with pytest.warns(FutureWarning, match="non-2-dimensional X"): |
31 | | - encoded = encoder.fit_transform(df.category, df.label) |
32 | | - answer = np.array([1.0, 1.0, 0.0, 1.0])[:, None] |
33 | | - assert array_equal(encoded, answer) |
34 | | - |
35 | | - # Warns in fit |
36 | | - encoder = TargetEncoder(output_type="numpy") |
37 | | - with pytest.warns(FutureWarning, match="non-2-dimensional X"): |
38 | | - encoder.fit(df.category, df.label) |
39 | | - |
40 | | - # Warns in tarnsform |
41 | | - with pytest.warns(FutureWarning, match="non-2-dimensional X"): |
42 | | - encoded = encoder.transform(df.category) |
43 | | - assert array_equal(encoded, answer) |
44 | | - |
45 | | - |
46 | 18 | def test_targetencoder_fit_transform(): |
47 | 19 | train = cudf.DataFrame({"category": ["a", "b", "b", "a"]}) |
48 | 20 | label = cudf.Series([1, 0, 1, 1]) |
|
0 commit comments